Skip to content

Commit

Permalink
docs(navigation): Note about params + path (vuejs#1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
posva authored Aug 15, 2017
1 parent 69ce269 commit 86ca8a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/en/essentials/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ router.push({ name: 'user', params: { userId: 123 }})
router.push({ path: 'register', query: { plan: 'private' }})
```

**Note**: `params` are ignored if a `path` is provided, which is not the case for `query`, as shown in the example above.
Instead, you need to provide the `name` of the route or manually specify the whole `path` with any parameter:

```js
const userId = 123
router.push({ name: 'user', params: { userId }}) // -> /user/123
router.push({ path: `/user/${userId}` }) // -> /user/123
// This will NOT work
router.push({ path: '/user', params: { userId }}) // -> /user
```

The same rules apply for the `to` property of the `router-link` component.

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.

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

0 comments on commit 86ca8a9

Please sign in to comment.