update the router guide
This commit is contained in:
1 parent
67992f7da9
commit
0d3ea377ce
63 files changed
+615
-1705
No files matched your search
@@ -4,10 +4,11 @@ When creating a router we need to pass it a [`Segment`]. It tells the router
|
||||
about all the routes of our app.
|
||||
|
||||
## Example content
|
||||
|
||||
To get a good understanding of how we define routes we first need to prepare
|
||||
some example content, so we can see the routing in action.
|
||||
|
||||
```rust,no_run
|
||||
```rust, no_run
|
||||
# // Hidden lines (like this one) make the documentation tests work.
|
||||
# extern crate dioxus;
|
||||
use dioxus::prelude::*;
|
||||
@@ -28,6 +29,7 @@ fn Other(cx: Scope) -> Element {
|
||||
```
|
||||
|
||||
## Index routes
|
||||
|
||||
The easiest thing to do is to define an index route.
|
||||
|
||||
Index routes act very similar to `index.html` files in most web servers. They
|
||||
@@ -36,7 +38,7 @@ are active, when we don't specify a route.
|
||||
> Note that we wrap our `Index` component with [`comp`]. This is because of
|
||||
> rust type system requirements.
|
||||
|
||||
```rust,no_run
|
||||
```rust, no_run
|
||||
# // Hidden lines (like this one) make the documentation tests work.
|
||||
# extern crate dioxus;
|
||||
# use dioxus::prelude::*;
|
||||
@@ -59,6 +61,7 @@ fn App(cx: Scope) -> Element {
|
||||
```
|
||||
|
||||
## Fixed routes
|
||||
|
||||
It is almost as easy to define a fixed route.
|
||||
|
||||
Fixed routes work similar to how web servers treat files. They are active, when
|
||||
@@ -66,7 +69,7 @@ specified in the path. In the example, the path must be `/other`.
|
||||
|
||||
> The path will be URL decoded before checking if it matches our route.
|
||||
|
||||
```rust,no_run
|
||||
```rust, no_run
|
||||
# // Hidden lines (like this one) make the documentation tests work.
|
||||
# extern crate dioxus;
|
||||
# use dioxus::prelude::*;
|
||||
@@ -91,7 +94,8 @@ fn App(cx: Scope) -> Element {
|
||||
```
|
||||
|
||||
## Full Code
|
||||
```rust
|
||||
|
||||
```rust, no_run
|
||||
# // Hidden lines (like this one) make the documentation tests work.
|
||||
# extern crate dioxus;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
Reference in new issue
Block a user