Skip to content

Commit 86ca8a9

Browse files
authored
docs(navigation): Note about params + path (vuejs#1680)
1 parent 69ce269 commit 86ca8a9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/en/essentials/navigation.md

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ router.push({ name: 'user', params: { userId: 123 }})
3030
router.push({ path: 'register', query: { plan: 'private' }})
3131
```
3232

33+
**Note**: `params` are ignored if a `path` is provided, which is not the case for `query`, as shown in the example above.
34+
Instead, you need to provide the `name` of the route or manually specify the whole `path` with any parameter:
35+
36+
```js
37+
const userId = 123
38+
router.push({ name: 'user', params: { userId }}) // -> /user/123
39+
router.push({ path: `/user/${userId}` }) // -> /user/123
40+
// This will NOT work
41+
router.push({ path: '/user', params: { userId }}) // -> /user
42+
```
43+
44+
The same rules apply for the `to` property of the `router-link` component.
45+
3346
In 2.2.0+, optionally provide `onComplete` and `onAbort` callbacks to `router.push` or `router.replace` as the 2nd and 3rd arguments. These callbacks will be called when the navigation either successfully completed (after all async hooks are resolved), or aborted (navigated to the same route, or to a different route before current navigation has finished), respectively.
3447

3548
#### `router.replace(location, onComplete?, onAbort?)`

0 commit comments

Comments
 (0)