Skip to content

Empty parent in nested routes #745

@rayfranco

Description

@rayfranco

It could be interesting to have a parent route definition without any component and having the matched children rendered in the root <router-view>. Here is an example:

var routes = [
  {
    path: '/:lang',
    children: [
      {
        path: '',
        component: WelcomeComponent
      },
      {
        path: 'hello/:name',
        component: HelloComponent
      }
    ]
  }
]

This won't work. Instead, this is what I am doing:

var routes = [
  {
    path: '/:lang',
    // create a container component
    component: {
      render (c) { return c('router-view') }
    },
    children: [
      {
        path: '',
        component: WelcomeComponent
      },
      {
        path: 'hello/:name',
        component: HelloComponent
      }
    ]
  }
]

But the original problem was to scope my routes by their definitions only, not by components.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions