我设置3个一级路由,然后想在这3个一级路由的子路由下渲染各自不同的404页面。404路径匹配不对
const routes = [
{
path: "/",
name: "home",
component: () => import("@/components/HelloWorld.vue"),
},
{
path: "/b",
name: "b",
component: () => import("@/views/b/index.vue"),
children: [
{
path: "b1",
name: "b1",
component: () => import("@/views/b/b1.vue"),
},
{
path: "/:pathMatch(.*)*",
name: "BNotFound",
component: () => import("@/views/b/BNotFound.vue"),
},
],
},
{
path: "/c",
name: "c",
component: () => import("@/views/c/index.vue"),
children: [
{
path: "c1",
name: "c1",
component: () => import("@/views/c/c1.vue"),
},
{
path: "/:pathMatch(.*)*",
name: "CNotFound",
component: () => import("@/views/c/CNotFound.vue"),
},
],
},
{
path: "/:pathMatch(.*)*",
name: "NotFound",
component: () => import("@/views/NotFound.vue"),
},
]
为什么我访问"/c/c2"路径时,匹配到的是B的404页面即 BNotFound,而不是 CNotFound。如何改正?
AI 回答的不对,我用的是最新的 vue-router 版本 4.3.0。(我已经知道解决方法了,就在之前方式加点东西搞定各种情况下的不同404页面 )
报错:vue-router.js?v=36532544:975 Uncaught Error: Catch all routes ("*") must now be defined using a param with a custom regexp