basic.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //! Basic example that renders a simple domtree to the browser.
  2. use dioxus_core::prelude::*;
  3. use dioxus_web::*;
  4. fn main() {
  5. // Setup logging
  6. wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
  7. // wasm_logger::init(wasm_logger::Config::with_prefix(
  8. // log::Level::Debug,
  9. // "dioxus_core",
  10. // ));
  11. console_error_panic_hook::set_once();
  12. // Run the app
  13. wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
  14. }
  15. static App: FC<()> = |ctx, _| {
  16. log::info!("Ran component");
  17. use dioxus::builder::*;
  18. ctx.view(|b| {
  19. div(b)
  20. .child(text("hello"))
  21. .listeners([on(b, "click", |_| {
  22. //
  23. log::info!("button1 clicked!");
  24. })])
  25. .finish()
  26. })
  27. // ctx.view(html! {
  28. // <div onclick={move |_| log::info!("button1 clicked!")}>
  29. // "Hello"
  30. // // <div class="flex items-center justify-center flex-col">
  31. // // <div class="font-bold text-xl"> "Count is ..." </div>
  32. // // <button onclick={move |_| log::info!("button1 clicked!")}> "increment" </button>
  33. // // <button onclick={move |_| log::info!("button2 clicked!")}> "decrement" </button>
  34. // // </div>
  35. // </div>
  36. // })
  37. };