Skip to content

Support for multiple nested empty subroute paths #908

@decademoon

Description

@decademoon
Contributor

Vue version: 2.0.6
Vue-router version: 2.0.2
Reproduction link: http://jsfiddle.net/4wogLvcd/

Given the following routes:

const A = { template: '<div>A <router-view/></div>' };
const B = { template: '<div>B <router-view/></div>' };
const C = { template: '<div>C</div>' };

{
  path: '/a',
  name: 'a',
  component: A,
  children: [
    {
      path: '',
      name: 'b',
      component: B,
      children: [
        {
          path: '',
          name: 'c',
          component: C,
        },
      ],
    },
  ],
}

When matching against the path /a, vue-router will return the b route instead of c. vue-router version 1 correctly returned route c in this case.

Also, vue-router seems to associate route b with path /a/, why the trailing slash? Shouldn't path /a always be resolved to route c (regardless of any trailing slash)?

I managed to get it working the way I want by changing in the addRouteRecord function

pathMap[record.path] = record

to

if (!pathMap[record.path]) pathMap[record.path] = record

that way only the deepest route will be associated with the path, but I don't know if this breaks anything else. What do you think?

Activity

Jordy-A

Jordy-A commented on Nov 25, 2016

@Jordy-A

Same issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yyx990803@decademoon@Jordy-A

        Issue actions

          Support for multiple nested empty subroute paths · Issue #908 · vuejs/vue-router