dioxus/packages/web/examples/basic.rs

24 lines
746 B
Rust
Raw Normal View History

//! basic example that renders a simple domtree to the page :)
2021-02-23 20:08:23 +00:00
use dioxus_core::prelude::*;
use dioxus_web::*;
fn main() {
2021-02-23 20:08:23 +00:00
// Enable logging
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
2021-02-23 20:08:23 +00:00
// Route panic as console_log
2021-02-17 15:53:55 +00:00
console_error_panic_hook::set_once();
2021-02-23 20:08:23 +00:00
// Render the app
WebsysRenderer::simple_render(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>
});
}