1
0

router_cfg.rs 813 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // ANCHOR: router
  2. #![allow(non_snake_case)]
  3. use dioxus::prelude::*;
  4. use dioxus_router::prelude::*;
  5. /// An enum of all of the possible routes in the app.
  6. #[derive(Routable, Clone)]
  7. enum Route {
  8. // The home page is at the / route
  9. #[route("/")]
  10. // If the name of the component and variant are the same you can omit the component and props name
  11. // #[route("/", ComponentName, PropsName)]
  12. Home {},
  13. }
  14. // ANCHOR_END: router
  15. // ANCHOR: app
  16. #[inline_props]
  17. fn App(cx: Scope) -> Element {
  18. render! {
  19. Router {
  20. config: || RouterConfig::default().history(WebHistory::default())
  21. }
  22. }
  23. }
  24. // ANCHOR_END: app
  25. // ANCHOR: home
  26. #[inline_props]
  27. fn Home(cx: Scope) -> Element {
  28. render! {
  29. h1 { "Welcome to the Dioxus Blog!" }
  30. }
  31. }
  32. // ANCHOR_END: home
  33. fn main() {}