- 定义路由表
import { createRouter, createWebHashHistory } from "vue-router";
const routes = [
{
path: "/",
name: "home",
component: Home,
},
// ...
{
path: "/404",
name: "404",
component: () =>
import(/* webpackChunkName: "404" */ "../views/404"),
},
{
// 此处vue3更新需要使用catchall方法匹配,不然会出现错误:
// Catch all routes ("*") must now be defined using a param with a custom regexp
path: "/:catchAll(.*)",
redirect: "/404",
},
]
标签:import,vue3,404,跳转,path,路由表
From: https://www.cnblogs.com/nancheng0/p/17293077.html