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 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
Original file line number Diff line number Diff line change @@ -45,12 +45,16 @@ router.map({
4545
4646``` js
4747router .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### テンプレートでの使用
You can’t perform that action at this time.
0 commit comments