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

 

posted @ 2022-02-24 11:43  文采呱呱  阅读(189)  评论(0编辑  收藏  举报