Vue-router: meta object empty

Created on 19 Jul 2017  路  4Comments  路  Source: vuejs/vue-router

Version

2.2.0

Reproduction link

https://github.com/gomonk3037/vue-chalkack

Steps to reproduce

Before

export default [
  {
    path: '/home',
    meta: { requiresAuth: true },
    name: 'UserPage',
    component: UserPage,
  },
];

Current

export default [
  {
    path: '/home',
    meta: { requiresAuth: true },
    component: UserPage,
    children: [
      {
        path: '',
        name: 'UserPage',
        component: MainPage,
      },
    ],
  },
];

What is expected?

Children inherit meta value of the parent router object

What is actually happening?

meta object empty in '/home' route & children route

All 4 comments

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server, gitter or StackOverflow.


Sharing your whole project as the repo is just too much... If you manage to boil it down in a jsfiddle, I can take a look

@posva
I'm sorry I uploaded the wrong issue because I did not know it was really a bug.

'/foo' click => console log shows that the meta object for the route object is empty
https://jsfiddle.net/jm84numq/2/

I think this is by design, not a bug - although a way to access the parent route from beforeEach would be really nice.

Yeah, it's by design. Inheriting meta fields can be problematic. To get access to the meta fields of the parent, you have to look at the matched property

Was this page helpful?
0 / 5 - 0 ratings