Skip to content

Commit

Permalink
docs(zh): add promise based push/replace (#2898)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
2 people authored and posva committed Aug 22, 2019
1 parent e0d4dc4 commit a8fe4fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/zh/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ router.afterEach((to, from) => {})
``` js
router.push(location, onComplete?, onAbort?)
router.push(location).then(onComplete).catch(onAbort)
router.replace(location, onComplete?, onAbort?)
router.replace(location).then(onComplete).catch(onAbort)
router.go(n)
router.back()
router.forward()
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guide/essentials/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ router.push({ path: '/user', params: { userId }}) // -> /user

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

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

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

Expand Down

0 comments on commit a8fe4fc

Please sign in to comment.