mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-24 03:23:11 +00:00
39 lines
730 B
Rust
39 lines
730 B
Rust
//! Basic example that renders a simple domtree to the browser.
|
|
|
|
use dioxus_core::prelude::*;
|
|
use dioxus_web::*;
|
|
|
|
fn main() {
|
|
// Setup logging
|
|
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
|
console_error_panic_hook::set_once();
|
|
|
|
// Run the app
|
|
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
|
}
|
|
|
|
static App: FC<()> = |ctx, _| {
|
|
ctx.render(rsx! {
|
|
div {
|
|
h1 {"hello"}
|
|
C1 {}
|
|
C2 {}
|
|
}
|
|
})
|
|
};
|
|
|
|
static C1: FC<()> = |ctx, props| {
|
|
ctx.render(rsx! {
|
|
button {
|
|
"numba 1"
|
|
}
|
|
})
|
|
};
|
|
|
|
static C2: FC<()> = |ctx, props| {
|
|
ctx.render(rsx! {
|
|
button {
|
|
"numba 2"
|
|
}
|
|
})
|
|
};
|