Vue3 は 404 構成を変更したため、通常のマッチングを使用する必要があります
通常のパラメータは、 で区切られた URL フラグメント間の文字のみと一致します
/
。任意の path と一致させたい場合は、カスタムの path パラメータ 正規表現を使用して、 path パラメータ の後に括弧内に正規表現を追加します。
import {
createRouter,
createWebHashHistory
} from 'vue-router'
const routes = [
{
path: '/404',
name: 'NoPage404',
component: NoPage,
hidden: true
},
{
path: '/:pathMatch(.*)',
redirect: '/404',
hidden: true
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router