File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
同じルーターにフックする前に複数のグローバルを追加できます。これらのフックは作成の順序で呼ばれます。フックは非同期に解決することができるため、前のものが解決されるまで次のフックは呼び出されません。
6
6
7
+ グローバル before フックは[ フックの解決ルール] ( ../pipeline/hooks.html#フックの解決ルール ) と同じように解決されます。
8
+
7
9
### 引数
8
10
9
11
- ` hook {Function} `
10
12
11
- hook 関数は[ トランジションオブジェクト] ( ../pipeline/hooks.html#transition-object ) な単一の引数を受信します。
13
+ hook 関数は[ トランジションオブジェクト] ( ../pipeline/hooks.html#トランジションオブジェクト ) な単一の引数を受信します。
12
14
13
15
### 戻り値
14
16
Original file line number Diff line number Diff line change @@ -45,12 +45,16 @@ router.map({
45
45
46
46
``` js
47
47
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 ()
50
52
}
51
53
})
52
54
```
53
55
56
+ どのように ` beforeEach ` フックが動作するかは、[ API] ( api/before-each.md ) を参照してください。
57
+
54
58
ネストされた route がマッチされるとき、全てのカスタムフィールドは同じ ` $route ` オブジェクトにマージされます。サブ route と 親 route が同じカスタムフィールドを持っているとき、サブ route の値は親の値で上書きされます。
55
59
56
60
### テンプレートでの使用
You can’t perform that action at this time.
0 commit comments