8000 fix: update ja docs by kazupon · Pull Request #3214 · vuejs/vue-router · GitHub
[go: up one dir, main page]

Skip to content

fix: update ja docs #3214

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

Merged
merged 20 commits into from
Jun 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(ja): update
NOTE: e014630
  • Loading branch information
kazupon committed May 29, 2020
commit df1cebc57bd25c190068c12ede8a5a44fa164c46
19 changes: 18 additions & 1 deletion docs/ja/guide/advanced/navigation-guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,24 @@ router.beforeEach((to, from, next) => {

- **`next(error)`**: (2.4.0+) `next` に渡された引数が `Error` インスタンスである場合、ナビゲーションは中止され、エラーは `router.onError()` を介して登録されたコールバックに渡されます。

**各ナビゲーションガードで、常に 1回だけ `next` 関数を呼び出すようにしてください。そうしなければ、フックは決して解決されない、またはエラーが発生します。**
**Make sure that the `next` function is called exactly once in any given navigation guard. It can appear more than once, but only if the logical paths have no overlap, otherwise the hook will never be resolved or produce errors.** Here is an example of redirecting to user to `/login` if they are not authenticated:

```js
// BAD
router.beforeEach((to, from, next) => {
if (!isAuthenticated) next('/login')
// if the user is not authenticated, `next` is called twice
next()
})
```

```js
// GOOD
router.beforeEach((to, from, next) => {
if (!isAuthenticated) next('/login')
else next()
})
```

## グローバル解決ガード

Expand Down
0