[Vuejs]-How to get component name or the python from vue-router?

-1đź‘Ť

âś…

First of all, there is no “components” property on vue-router.

You need to use “component” property to inject your shell component (in this case, it looks like WhoisPage) then you can call your sub-components to build your page inside your shell component.

If you want to change your sub-components based on route automatically, you can send their names as string and render in your shell-component.

// in your router config.

export default new Router({
  routes: [
    {
      path: '/',
      component: WhoisPage,
      meta: {
        navbar: 'NavbarComponent'
      }
    }
  ]
})
<!-- in your shell component, ofc your navbar needs to be imported -->

<component :is="$route.meta.navbar"></component>

Not sure i correctly answered what you need tho.

Leave a comment