//方式一:保留错误的url(推荐)
{ path: "*", component: PageC,name:'404' },
//方式二:不保留错误的url 直接重定向
{ path: "/page3", component: PageC, name:'404' },
{ path: "*", redirect: '/page3'},
//方式三:路由守卫
router.beforeEach((to,from,next)=>{
if(to.matched.length === 0){
// next({ path: '/page3' })
//或者
next({ name: '404' })
}else{
next()
}
})
vue-router 配置404页面
最新推荐文章于 2024-08-04 21:39:31 发布