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

[Vue Router warn]: Finding ancestor route "/:path(.*)*" failed for "/:path(.*)*" #2266

Closed
rex-ll opened this issue Jun 11, 2024 · 3 comments
Closed

Comments

@rex-ll
Copy link

rex-ll commented Jun 11, 2024

Reproduction

RT

Steps to reproduce the bug

After upgrading to the latest version

{ path: '/:path(.*)*', name: PAGE_NOT_FOUND_NAME, component: LAYOUT, meta: { title: 'ErrorPage', }, children: [ { path: '/:path(.*)*', name: PAGE_NOT_FOUND_NAME, component: EXCEPTION_COMPONENT, meta: { title: 'ErrorPage', }, }, ], }

Expected behavior

no warning

Actual behavior

warning log

Additional information

No response

@skirtles-code
Copy link
Contributor

I think I managed to reproduce this:

But it only happens if there are two routes with the same name. This is probably something that should be handled better, but is there any reason why you need two routes with the same name? You should be able to avoid this warning just by removing the name option from the parent route.

@posva
Copy link
Member

posva commented Jun 11, 2024

names must be unique, this is what you need to write instead:

{
  path: '/:path(.*)*',
  component: LAYOUT,
  meta: { title: 'ErrorPage' },
  children:
    [
      {
        path: '',
        name: PAGE_NOT_FOUND_NAME,
        component: EXCEPTION_COMPONENT,
        meta: { title: 'ErrorPage' },
      },
    ],
}

@CDwenhuohuo
Copy link

谢谢

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

4 participants