dioxus/packages/web/examples/basic.rs

21 lines
638 B
Rust
Raw Normal View History

2021-02-24 07:22:05 +00:00
//! Basic example that renders a simple domtree to the browser.
2021-02-23 20:08:23 +00:00
use dioxus_core::prelude::*;
use dioxus_web::*;
fn main() {
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-02-24 07:22:05 +00:00
static App: FC<()> = |ctx, _| {
ctx.view(html! {
2021-02-17 15:53:55 +00:00
<div>
<div class="flex items-center justify-center flex-col">
<div class="font-bold text-xl"> "Count is {}" </div>
<button onclick={move |_| log::info!("button1 clicked!")}> "increment" </button>
<button onclick={move |_| log::info!("button2 clicked!")}> "decrement" </button>
</div>
</div>
2021-02-24 07:22:05 +00:00
})
};