1
0

basic.rs 730 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. console_error_panic_hook::set_once();
  8. // Run the app
  9. wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
  10. }
  11. static App: FC<()> = |ctx, _| {
  12. ctx.render(rsx! {
  13. div {
  14. h1 {"hello"}
  15. C1 {}
  16. C2 {}
  17. }
  18. })
  19. };
  20. static C1: FC<()> = |ctx, props| {
  21. ctx.render(rsx! {
  22. button {
  23. "numba 1"
  24. }
  25. })
  26. };
  27. static C2: FC<()> = |ctx, props| {
  28. ctx.render(rsx! {
  29. button {
  30. "numba 2"
  31. }
  32. })
  33. };