Skip to content

Commit 1381850

Browse files
committed
docs: add promise based push/replace
[ci skip]
1 parent bb37f83 commit 1381850

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: docs/api/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ Signatures:
354354

355355
```js
356356
router.push(location, onComplete?, onAbort?)
357+
router.push(location).then(onComplete).catch(onAbort)
357358
router.replace(location, onComplete?, onAbort?)
359+
router.replace(location).then(onComplete).catch(onAbort)
358360
router.go(n)
359361
router.back()
360362
router.forward()

Diff for: docs/guide/essentials/navigation.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ router.push({ path: '/user', params: { userId } }) // -> /user
4747
The same rules apply for the `to` property of the `router-link` component.
4848

4949
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.
50+
In 3.1.0+, you can ommit the 2nd and 3rd parameter and `router.push`/`router.replace` will return a promise instead if Promises are supported.
5051

5152
**Note:** If the destination is the same as the current route and only params are changing (e.g. going from one profile to another `/users/1` -> `/users/2`), you will have to use [`beforeRouteUpdate`](./dynamic-matching.md#reacting-to-params-changes) to react to changes (e.g. fetching the user information).
5253

0 commit comments

Comments
 (0)