Skip to content

Commit f30cdfe

Browse files
committed
Updated router optional parameter documentation
1 parent b5c2154 commit f30cdfe

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/plugins/router/navigation.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,41 @@ Router.navigate({
9696

9797
This results in: `#player/12/44`
9898

99+
## Optional router path
100+
101+
You can also specify the optional router path parameter to the Router path.
102+
This is an advantage as we need not specify two different routes to the same component, instead we can specify optional field in router path with a '?' suffix for the optional params.
103+
104+
```js
105+
{
106+
path: 'player/:assetId/:playlistId?',
107+
component: Player
108+
name: 'player'
109+
}
110+
```
111+
112+
This will generate two paths as below:
113+
114+
```js
115+
{
116+
path: 'player/:assetId/:playlistId'
117+
component: Player
118+
name: 'player'
119+
}
120+
```
121+
```js
122+
{
123+
path: 'player/:assetId/',
124+
component: Player,
125+
name: 'player'
126+
}
127+
```
128+
129+
Note: This will not work if the optional parameter ? is in the middle of the path. For Ex :
130+
```js
131+
path: 'player/:assetId?/:playlistId'
132+
```
133+
99134

100135
## isNavigating Method
101136

0 commit comments

Comments
 (0)