Merge branch 'router-2' of github.com:TeFiLeDo/dioxus into router-2
This commit is contained in:
commit
96c69b2437
2 files changed
+30
-4
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
use dioxus_router_core::history::MemoryHistory;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
dioxus_desktop::launch(App);
|
dioxus_desktop::launch(App);
|
||||||
@@ -11,19 +12,44 @@ fn App(cx: Scope) -> Element {
|
|||||||
use_router(
|
use_router(
|
||||||
&cx,
|
&cx,
|
||||||
&|| RouterConfiguration {
|
&|| RouterConfiguration {
|
||||||
|
// history: Box::new(MemoryHistory::with_initial_path("/apple").unwrap()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
&|| Segment::content(comp(RootIndex)),
|
&|| Segment::content(comp(RootIndex)).fixed("apple", comp(Apple)),
|
||||||
);
|
);
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
h1 { "hi" }
|
h1 { "Simple Example App" }
|
||||||
|
nav {
|
||||||
|
Link {
|
||||||
|
target: named::<RootIndex>(),
|
||||||
|
"Go to root"
|
||||||
|
}
|
||||||
|
}
|
||||||
Outlet { }
|
Outlet { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn RootIndex(cx: Scope) -> Element {
|
fn RootIndex(cx: Scope) -> Element {
|
||||||
render! {
|
render! {
|
||||||
h1 { "Simple Example App" }
|
h2 { "Root Index" }
|
||||||
|
ul {
|
||||||
|
li {
|
||||||
|
Link {
|
||||||
|
target: "/apple",
|
||||||
|
"Read about apples…"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Apple(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h2 { "Apple" }
|
||||||
|
p {
|
||||||
|
"An apple is a tasty fruit. It grows on trees and many varieties are either red or "
|
||||||
|
"green."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,6 @@ pub fn Outlet(cx: Scope<OutletProps>) -> Element {
|
|||||||
let X = content.0;
|
let X = content.0;
|
||||||
rsx! { X { } }
|
rsx! { X { } }
|
||||||
}
|
}
|
||||||
None => rsx! { Fragment { } },
|
None => rsx! { div { } },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user