2021-06-01 22:33:15 +00:00
|
|
|
//! Basic example that renders a simple VNode to the browser.
|
2021-02-23 20:08:23 +00:00
|
|
|
|
2021-06-22 21:20:54 +00:00
|
|
|
use dioxus_core as dioxus;
|
2021-02-15 05:17:40 +00:00
|
|
|
use dioxus_core::prelude::*;
|
|
|
|
use dioxus_web::*;
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-26 17:58:03 +00:00
|
|
|
// Setup logging
|
|
|
|
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
|
|
|
console_error_panic_hook::set_once();
|
|
|
|
|
|
|
|
// Run the app
|
2021-02-24 07:22:05 +00:00
|
|
|
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
|
|
|
}
|
2021-02-23 20:08:23 +00:00
|
|
|
|
2021-06-01 22:33:15 +00:00
|
|
|
static App: FC<()> = |ctx| {
|
2021-03-11 17:27:01 +00:00
|
|
|
ctx.render(rsx! {
|
|
|
|
div {
|
|
|
|
h1 {"hello"}
|
|
|
|
C1 {}
|
|
|
|
C2 {}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2021-06-01 22:33:15 +00:00
|
|
|
static C1: FC<()> = |ctx| {
|
2021-03-11 17:27:01 +00:00
|
|
|
ctx.render(rsx! {
|
|
|
|
button {
|
|
|
|
"numba 1"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2021-06-01 22:33:15 +00:00
|
|
|
static C2: FC<()> = |ctx| {
|
2021-03-11 17:27:01 +00:00
|
|
|
ctx.render(rsx! {
|
|
|
|
button {
|
|
|
|
"numba 2"
|
|
|
|
}
|
|
|
|
})
|
2021-02-24 07:22:05 +00:00
|
|
|
};
|
2021-06-15 14:02:46 +00:00
|
|
|
|
|
|
|
static DocExamples: FC<()> = |ctx| {
|
|
|
|
//
|
|
|
|
|
|
|
|
let is_ready = false;
|
|
|
|
|
|
|
|
let items = (0..10).map(|i| rsx! { li {"{i}"} });
|
|
|
|
let _ = rsx! {
|
|
|
|
ul {
|
|
|
|
{items}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-22 21:20:54 +00:00
|
|
|
// rsx! {
|
|
|
|
// div {}
|
|
|
|
// h1 {}
|
|
|
|
// {""}
|
|
|
|
// "asbasd"
|
|
|
|
// dioxus::Fragment {
|
|
|
|
// //
|
|
|
|
// }
|
|
|
|
// }
|
2021-06-15 14:02:46 +00:00
|
|
|
|
|
|
|
ctx.render(rsx! {
|
|
|
|
div {
|
|
|
|
{ is_ready.then(|| rsx!{ h1 {"We are ready!"} }) }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|