-
-
Notifications
You must be signed in to change notification settings - Fork 5k
docs(zh): translate navigation-failures.md to chinese. #3416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
> 3.4.0中新增 | ||
|
||
::: tip 译者注 | ||
_导航故障_,或者叫_导航失败_,表示一次失败的导航,原文 navigation failures,本文统一采用 _导航故障_。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文使用 *
来标注斜体吧,可以不需要加额外的空格了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,顺便问一下,我要怎么修改?是在我本地改完之后push吗?对pr流程还不是太熟悉[捂脸]
|
||
当使用 `router-link` 组件时,Vue Router 会自动调用 `router.push` 来触发一次导航。 虽然大多数链接的预期行为是将用户导航到一个新页面,但也有少数情况下用户将留在同一页面上: | ||
|
||
- 用户已经位于他们正在尝试导航的页面了 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 用户已经位于他们正在尝试导航的页面了 | |
- 用户已经位于他们正在尝试导航到的页面 |
- 一个[导航守卫](./navigation-guards.md)通过调用 `next(false)` 中断了这次导航 | ||
- 一个[导航守卫](./navigation-guards.md)抛出了一个错误,或者调用了 `next(new Error())` | ||
|
||
当使用 `router-link` 组件时,**这些失败都不会打印出错误**。然而,如果你使用 `router.push` 或者 `router.replace` 的话,你可能就会在控制台看到一条 _"Uncaught (in promise) Error"_ 这样的错误,后面会跟着一条更具体的消息。让我们了解如何区分 _导航故障_。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当使用 `router-link` 组件时,**这些失败都不会打印出错误**。然而,如果你使用 `router.push` 或者 `router.replace` 的话,你可能就会在控制台看到一条 _"Uncaught (in promise) Error"_ 这样的错误,后面会跟着一条更具体的消息。让我们了解如何区分 _导航故障_。 | |
当使用 `router-link` 组件时,**这些失败都不会打印出错误**。然而,如果你使用 `router.push` 或者 `router.replace` 的话,可能会在控制台看到一条 _"Uncaught (in promise) Error"_ 这样的错误,后面跟着一条更具体的消息。让我们来了解一下如何区分*导航故障*。 |
当使用 `router-link` 组件时,**这些失败都不会打印出错误**。然而,如果你使用 `router.push` 或者 `router.replace` 的话,你可能就会在控制台看到一条 _"Uncaught (in promise) Error"_ 这样的错误,后面会跟着一条更具体的消息。让我们了解如何区分 _导航故障_。 | ||
|
||
::: tip 背景故事 | ||
在 v3.2.0 中,通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露 _导航故障_。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个 _Promise_。用这个 _Promise_ 的 resolve 和 reject 来代替 `onComplete` 和 `onAbort` 的调用。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 v3.2.0 中,通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露 _导航故障_。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个 _Promise_。用这个 _Promise_ 的 resolve 和 reject 来代替 `onComplete` 和 `onAbort` 的调用。 | |
在 v3.2.0 中,可以通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露*导航故障*。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个*Promise*。这个*Promise*的 resolve 和 reject 将分别用来代替 `onComplete` 和 `onAbort` 的调用。 |
import VueRouter from 'vue-router' | ||
const { isNavigationFailure, NavigationFailureType } = VueRouter | ||
|
||
// trying to access the admin page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释需要翻译一下,下同
``` | ||
|
||
::: tip | ||
如果你忽略第二个参数:`isNavigationFailure(failure)`,那么只会检查这个错误是不是一个 _导航故障_。(言外之意:不会检查它到底是哪一种导航故障) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
翻译最好还是不要自己解释太多,改变原文的话最好给原文也提一下 PR。
当使用 `router-link` 组件时,**这些失败都不会打印出错误**。然而,如果你使用 `router.push` 或者 `router.replace` 的话,可能会在控制台看到一条 _"Uncaught (in promise) Error"_ 这样的错误,后面跟着一条更具体的消息。让我们来了解一下如何区分*导航故障*。 | ||
|
||
::: tip 背景故事 | ||
在 v3.2.0 中,可以通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露*导航故障*。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个*Promise*。这个*Promise*的 resolve 和 reject 将分别用来代替 `onComplete` 和 `onAbort` 的调用。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 v3.2.0 中,可以通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露*导航故障*。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个*Promise*。这个*Promise*的 resolve 和 reject 将分别用来代替 `onComplete` 和 `onAbort` 的调用。 | |
在 v3.2.0 中,可以通过使用 `router.push` 的两个可选的回调函数:`onComplete` 和 `onAbort` 来暴露*导航故障*。从版本 3.1.0 开始,`router.push` 和 `router.replace` 在没有提供 `onComplete`/`onAbort` 回调的情况下会返回一个 *Promise*。这个 *Promise* 的 resolve 和 reject 将分别用来代替 `onComplete` 和 `onAbort` 的调用。 |
Thanks! |
No description provided.