vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.74k stars 1.15k forks source link

@4.3.3 the redirect / to home is not effective when children get /:pathMatch(.*) #2268

Closed sherleysong closed 3 weeks ago

sherleysong commented 3 weeks ago

Reproduction

https://jsfiddle.net/5qv469nr/2/

Steps to reproduce the bug

{ path: '/', redirect: '/foo' }, { path: '/foo', component: Foo }, { path: '/:pathMatch(.*)', component: Bar }

Expected behavior

goto foo

Actual behavior

goto bar

Additional information

{ path: '/', redirect: '/foo' }, // when come to "/" , I hope go to foo page which is my actural home page { path: '/foo', component: Foo }, { path: '/:pathMatch(.*)', // when not "/ " or not "foo", I hope go to bar page , which is my 404 page . component: Bar }

the actural code is like this :

{ path: '/', name: 'home', component: Main, redirect: '/home', meta: { title: '首页' }, children: [ { path: '/home', name: 'home', meta: { title: '首页' }, component: () => import('src/components/home') }, { path: '/:pathMatch(.*)', component: () => import('src/components/error-page/404.vue') } ] }

the code before vue-router@4.3.2 is OK , but wrong when come to vue-router@4.3.3 .

can you fix it @4.3.4 ?

posva commented 3 weeks ago

Duplicate of #2266

posva commented 3 weeks ago

You have duplicated names, remove the one you don't want