1
0

dynamic_segments.rs 829 B

1234567891011121314151617181920212223242526272829303132333435
  1. #![allow(non_snake_case, unused)]
  2. use dioxus::prelude::*;
  3. use dioxus_router::prelude::*;
  4. // ANCHOR: route
  5. #[derive(Routable, Clone)]
  6. #[rustfmt::skip]
  7. enum Route {
  8. // segments that start with : are dynamic segments
  9. #[route("/blog/:name")]
  10. BlogPost {
  11. // You must include dynamic segments in child variants
  12. name: String,
  13. },
  14. #[route("/document/:id")]
  15. Document {
  16. // You can use any type that implements FromStr
  17. // If the segment can't be parsed, the route will not match
  18. id: usize,
  19. },
  20. }
  21. // Components must contain the same dynamic segments as their corresponding variant
  22. #[inline_props]
  23. fn BlogPost(cx: Scope, name: String) -> Element {
  24. todo!()
  25. }
  26. #[inline_props]
  27. fn Document(cx: Scope, id: usize) -> Element {
  28. todo!()
  29. }
  30. // ANCHOR_END: route
  31. fn main() {}