You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins/router/navigation.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,46 @@ Router.navigate({
96
96
97
97
This results in: `#player/12/44`
98
98
99
+
## Optional router path
100
+
101
+
There might be some cases in which you need a route path with an optional parameter at the end. Normally, you would have to define two different routes to the same component, one with the optional parameter and one without. Starting with Lightning-SDK `v5.3.0`, you can specify an optional router path parameter by adding a `?` suffix to the last parameter name.
102
+
103
+
Please note that only the last parameter of any path is allowed to be an optional parameter. For example, if you have a route path with three parameters, you can make only the last parameter optional, but not the second parameter.
104
+
105
+
When we define an optional parameter like this:
106
+
```js
107
+
{
108
+
path:'player/:assetId/:playlistId?',
109
+
component: Player
110
+
name:'player'
111
+
}
112
+
```
113
+
114
+
This will generate two paths internally as below:
115
+
116
+
```js
117
+
{
118
+
path:'player/:assetId/:playlistId'
119
+
component: Player
120
+
name:'player'
121
+
}
122
+
{
123
+
path:'player/:assetId',
124
+
component: Player,
125
+
name:'player'
126
+
}
127
+
```
128
+
129
+
The following example would *not* work because only the last parameter of the path can be optional:
0 commit comments