Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple nested empty subroute paths #908

Closed
decademoon opened this issue Nov 16, 2016 · 1 comment
Closed

Support for multiple nested empty subroute paths #908

decademoon opened this issue Nov 16, 2016 · 1 comment

Comments

@decademoon
Copy link
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?

@Jordy-A
Copy link

Jordy-A commented Nov 25, 2016

Same issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants