Uncaught Error: Catch all routes ("") must now be defined using a param with a custom regexp.

image.png
設置404頁面
在router/index.ts中
import { App } from 'vue';
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
...
{
path: '*',
component: () => import('@/views/error/404.vue')
}
];
export const router = createRouter({
history: createWebHistory(),
routes
});
export const initRouter = (app: App<Element>) => {
return app.use(router);
};
解決方法
在vue-router@4.x中寫法不同
設置如下,即可正常訪問
{
path: '/:catchAll(.*)',
component: () => import('@/views/error/404.vue')
}