Sfoglia il codice sorgente

add simple example

Adrian Wannenmacher 2 anni fa
parent
commit
a170aa76e0
2 ha cambiato i file con 33 aggiunte e 0 eliminazioni
  1. 4 0
      packages/router/Cargo.toml
  2. 29 0
      packages/router/examples/simple.rs

+ 4 - 0
packages/router/Cargo.toml

@@ -23,3 +23,7 @@ log = "0.4.17"
 [features]
 regex = ["dioxus-router-core/regex"]
 serde = ["dioxus-router-core/serde"]
+
+[dev-dependencies]
+dioxus = { path = "../dioxus" }
+dioxus-desktop = { path = "../desktop" }

+ 29 - 0
packages/router/examples/simple.rs

@@ -0,0 +1,29 @@
+#![allow(non_snake_case)]
+
+use dioxus::prelude::*;
+use dioxus_router::prelude::*;
+
+fn main() {
+    dioxus_desktop::launch(App);
+}
+
+fn App(cx: Scope) -> Element {
+    use_router(
+        &cx,
+        &|| RouterConfiguration {
+            ..Default::default()
+        },
+        &|| Segment::content(comp(RootIndex)),
+    );
+
+    render! {
+        h1 { "hi" }
+        Outlet { }
+    }
+}
+
+fn RootIndex(cx: Scope) -> Element {
+    render! {
+        h1 { "Simple Example App" }
+    }
+}