Skip to content

Commit a8fe4fc

Browse files
a631807682Justineo
authored andcommitted
docs(zh): add promise based push/replace (#2898)
* docs(zh): add promise based push/replace * docs(zh): clarifying omit the 2nd and 3rd parameter behaviour * Update docs/zh/guide/essentials/navigation.md Co-Authored-By: GU Yiling <[email protected]>
1 parent e0d4dc4 commit a8fe4fc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: docs/zh/api/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ router.afterEach((to, from) => {})
316316

317317
``` js
318318
router.push(location, onComplete?, onAbort?)
319+
router.push(location).then(onComplete).catch(onAbort)
319320
router.replace(location, onComplete?, onAbort?)
321+
router.replace(location).then(onComplete).catch(onAbort)
320322
router.go(n)
321323
router.back()
322324
router.forward()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ router.push({ path: '/user', params: { userId }}) // -> /user
4646

4747
同样的规则也适用于 `router-link` 组件的 `to` 属性。
4848

49-
在 2.2.0+,可选的在 `router.push``router.replace` 中提供 `onComplete``onAbort` 回调作为第二个和第三个参数。这些回调将会在导航成功完成 (在所有的异步钩子被解析之后) 或终止 (导航到相同的路由、或在当前导航完成之前导航到另一个不同的路由) 的时候进行相应的调用。
49+
在 2.2.0+,可选的在 `router.push``router.replace` 中提供 `onComplete``onAbort` 回调作为第二个和第三个参数。这些回调将会在导航成功完成 (在所有的异步钩子被解析之后) 或终止 (导航到相同的路由、或在当前导航完成之前导航到另一个不同的路由) 的时候进行相应的调用。在 3.1.0+,可以省略第二个和第三个参数,此时如果支持 Promise,`router.push``router.replace` 将返回一个 Promise。
5050

5151
**注意**: 如果目的地和当前路由相同,只有参数发生了改变 (比如从一个用户资料到另一个 `/users/1` -> `/users/2`),你需要使用 [`beforeRouteUpdate`](./dynamic-matching.md#响应路由参数的变化) 来响应这个变化 (比如抓取用户信息)。
5252

0 commit comments

Comments
 (0)