Skip to content

Commit c9639ab

Browse files
committed
docs(ja): improve dosc on how hooks work (ref 8925ce1)
1 parent 5e78f82 commit c9639ab

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/ja/api/before-each.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
同じルーターにフックする前に複数のグローバルを追加できます。これらのフックは作成の順序で呼ばれます。フックは非同期に解決することができるため、前のものが解決されるまで次のフックは呼び出されません。
66

7+
グローバル before フックは[フックの解決ルール](../pipeline/hooks.html#フックの解決ルール)と同じように解決されます。
8+
79
### 引数
810

911
- `hook {Function}`
1012

11-
hook 関数は[トランジションオブジェクト](../pipeline/hooks.html#transition-object)な単一の引数を受信します。
13+
hook 関数は[トランジションオブジェクト](../pipeline/hooks.html#トランジションオブジェクト)な単一の引数を受信します。
1214

1315
### 戻り値
1416

docs/ja/route.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ router.map({
4545

4646
``` js
4747
router.beforeEach(function (transition) {
48-
if (transition.to.auth) {
49-
// 認証する...
48+
if (transition.to.auth && !authenticated) {
49+
transition.redirect('/login')
50+
} else {
51+
transition.next()
5052
}
5153
})
5254
```
5355

56+
どのように `beforeEach` フックが動作するかは、[API](api/before-each.md) を参照してください。
57+
5458
ネストされた route がマッチされるとき、全てのカスタムフィールドは同じ `$route` オブジェクトにマージされます。サブ route と 親 route が同じカスタムフィールドを持っているとき、サブ route の値は親の値で上書きされます。
5559

5660
### テンプレートでの使用

0 commit comments

Comments
 (0)