vue3.0的404页面设置
就不bb那么多了,直接上代码好吧
import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' const routes = [ { path: '/', meta: { title: '首页', name: 'home' }, component: HomeView }, { path: '/about', name: 'about', component: () => import('../views/AboutView.vue') }, { path: '/MyView', name: 'MyView', component: () => import('../views/MyView.vue') }, { name:'404', path:'/404.html', component: () => import('../views/error/NotFoundView.vue') }, { path:'/:pathMatch(.*)*',//vue3.0模式 redirect:{ name:"404" } } ] const router = createRouter({ history: createWebHistory(), routes }) export default router
代码改变了我们,也改变了世界