Skip to content

Commit 840aacd

Browse files
committed
docs: feedback
1 parent f63dfe9 commit 840aacd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

docs/guide/essentials/route-matching-syntax.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Route Matching Syntax
1+
# Routes' Matching Syntax
22

33
Most applications will use static routes like `/about` and dynamic routes like `/users/:userId` like we just saw in [Dynamic Route Matching](./dynamic-matching.md), but Vue Router has much more to offer!
44

@@ -30,11 +30,15 @@ const routes = [
3030
]
3131
```
3232

33-
Make sure to **escape backslashes `\`** like we did with `\d` to actually pass the backslash character to a string in JavaScript.
33+
Now, going to `/25` will match `/:orderId` while going to anything else will match `/:productName`. The order of the `routes` array doesn't even matter!
34+
35+
:::tip
36+
Make sure to **escape backslashes (`\`)** like we did with `\d` (becomes `\\d`) to actually pass the backslash character in a string in JavaScript.
37+
:::
3438

3539
## Repeatable params
3640

37-
If you need to match routes with multiple sections like `/first/second/third`, you can mark a param as repeatable with `*` (0 or more) and `+` (1 or more):
41+
If you need to match routes with multiple sections like `/first/second/third`, you should mark a param as repeatable with `*` (0 or more) and `+` (1 or more):
3842

3943
```js
4044
const routes = [
@@ -64,14 +68,16 @@ These can also be combined with custom Regexp by adding them **after the closing
6468
```js
6569
const routes = [
6670
// only match numbers
71+
// matches /1, /1/2, etc
6772
{ path: '/:chapters(\\d+)+' },
73+
// matches /, /1, /1/2, etc
6874
{ path: '/:chapters(\\d+)*' },
6975
]
7076
```
7177

7278
## Optional parameters
7379

74-
You can also mark a parameter as optional by using the `?` modifier:
80+
You can also mark a parameter as optional by using the `?` modifier (0 or 1):
7581

7682
```js
7783
const routes = [
@@ -82,7 +88,7 @@ const routes = [
8288
]
8389
```
8490

85-
Note that `*` also marks the parameter as optional but cannot be repeated
91+
Note that `*` technically also marks a parameter as optional but `?` parameters cannot be repeated.
8692

8793
## Debugging
8894

0 commit comments

Comments
 (0)