dioxus/examples/link.rs

36 lines
1,008 B
Rust
Raw Normal View History

2022-01-18 09:19:12 +08:00
use dioxus::prelude::*;
use dioxus_router::{Link, Route, Router};
2022-01-18 09:19:12 +08:00
fn main() {
dioxus_desktop::launch(app);
2022-01-18 09:19:12 +08:00
}
fn app(cx: Scope) -> Element {
cx.render(rsx! (
2022-01-18 09:20:36 +08:00
div {
2022-01-18 09:19:12 +08:00
p {
a { href: "http://dioxuslabs.com/", "Default link - links outside of your app" }
2022-01-18 09:19:12 +08:00
}
p {
a {
href: "http://dioxuslabs.com/",
2022-01-18 14:52:14 +08:00
prevent_default: "onclick",
onclick: |_| println!("Hello Dioxus"),
2022-03-05 15:25:09 -05:00
"Custom event link - links inside of your app",
}
}
}
div {
Router {
Route { to: "/", h1 { "Home" } },
Route { to: "/settings", h1 { "settings" } },
p { "----"}
ul {
Link { to: "/", li { "Router link to home" } },
Link { to: "/settings", li { "Router link to settings" } },
2022-01-18 09:19:12 +08:00
}
}
}
))
}