File tree 3 files changed +5
-6
lines changed
examples/navigation-guards
3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ const router = new VueRouter({
57
57
]
58
58
} )
59
59
60
- // global hook that checks target route meta
60
+ // global hook that checks matched routes' meta to determine whether
61
+ // to guard the navigation
61
62
router . beforeEach ( ( route , redirect , next ) => {
62
- if ( route . meta . needGuard ) {
63
+ if ( route . matched . some ( m => m . meta . needGuard ) ) {
63
64
guardRoute ( route , redirect , next )
64
65
} else {
65
66
next ( )
@@ -70,7 +71,7 @@ const app = new Vue({
70
71
router,
71
72
template : `
72
73
<div id="app">
73
- <h1>Named Routes </h1>
74
+ <h1>Navigation Guards </h1>
74
75
<ul>
75
76
<li><router-link to="/">/</router-link></li>
76
77
<li><router-link to="/foo">/foo</router-link></li>
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ declare type Route = {
66
66
params: StringHash ;
67
67
fullPath: string ;
68
68
matched: Array < RouteRecord > ;
69
- meta: any ;
70
69
}
71
70
72
71
declare type Matcher = ( location : RawLocation , current ? : Route ) => Route ;
Original file line number Diff line number Diff line change @@ -57,8 +57,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
57
57
query : location . query || { } ,
58
58
params : location . params || { } ,
59
59
fullPath : getFullPath ( location ) ,
60
- matched : record ? formatMatch ( record ) : [ ] ,
61
- meta : record ? record . meta : { }
60
+ matched : record ? formatMatch ( record ) : [ ]
62
61
} )
63
62
}
64
63
You can’t perform that action at this time.
0 commit comments