Skip to content

Commit 416fea2

Browse files
committed
meta is exposed on matched records
1 parent 947e918 commit 416fea2

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

examples/navigation-guards/app.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ const router = new VueRouter({
5757
]
5858
})
5959

60-
// global hook that checks target route meta
60+
// global hook that checks matched routes' meta to determine whether
61+
// to guard the navigation
6162
router.beforeEach((route, redirect, next) => {
62-
if (route.meta.needGuard) {
63+
if (route.matched.some(m => m.meta.needGuard)) {
6364
guardRoute(route, redirect, next)
6465
} else {
6566
next()
@@ -70,7 +71,7 @@ const app = new Vue({
7071
router,
7172
template: `
7273
<div id="app">
73-
<h1>Named Routes</h1>
74+
<h1>Navigation Guards</h1>
7475
<ul>
7576
<li><router-link to="/">/</router-link></li>
7677
<li><router-link to="/foo">/foo</router-link></li>

flow/declarations.js

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ declare type Route = {
6666
params: StringHash;
6767
fullPath: string;
6868
matched: Array<RouteRecord>;
69-
meta: any;
7069
}
7170

7271
declare type Matcher = (location: RawLocation, current?: Route) => Route;

src/create-matcher.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
5757
query: location.query || {},
5858
params: location.params || {},
5959
fullPath: getFullPath(location),
60-
matched: record ? formatMatch(record) : [],
61-
meta: record ? record.meta : {}
60+
matched: record ? formatMatch(record) : []
6261
})
6362
}
6463

0 commit comments

Comments
 (0)