Skip to content

Commit 441f554

Browse files
fnlctrlyyx990803
authored andcommitted
Expose meta in Route objects (#602)
* Expose meta in Route objects Expose route.meta to allow reading RouteConfig.meta in transition hooks. Reasons: In 1.0, we used to pass Custom Fields( like `auth` in route configs, as the [document](http://router.vuejs.org/en/route.html#custom-fields) suggested), but in 2.0 these custom fields aren't exposed in `route` object. I've noticed that in `RouteConfig`, there is an optional field `meta`, which i guess serves the functionality of the previous Custom Fields, judging from the fact that 1). It's type is any 2).there are no references of it in the source code. So I guess `meta` should be exposed in route objects, otherwise there is no need to define it in the first place. * Update declarations.js * Update create-matcher.js
1 parent 9d8196a commit 441f554

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

flow/declarations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ declare type Route = {
6565
fullPath: string;
6666
matched: Array<RouteRecord>;
6767
redirectedFrom?: string;
68+
meta?: any;
6869
}
6970

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

src/create-matcher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export function createRoute (
126126
): Route {
127127
const route: Route = {
128128
name: location.name || (record && record.name),
129+
meta: (record && record.meta) || {},
129130
path: location.path || '/',
130131
hash: location.hash || '',
131132
query: location.query || {},

0 commit comments

Comments
 (0)