const routes = [
{
path: 'test1/:name/test2/:id',
name: 'Test',
component: () => import('@/pages/test.vue'),
},
]
<router-link to="/test1/jack/test2/123">jack</router-link>
<router-link to="/test1/mark/test2/456">mark</router-link>
const routes = [
// 将匹配所有内容并将其放在 `route.params.pathMatch` 下
{ path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
]
若寫 :pathMatch(.*)*
它可滿足,皆會進入元件
/404
/404?id=5
/404?id=5/news/user
:pathMatch(.*),若沒有最後面的 *
它就只能滿足,才進入元件
/404
/404?id=5