完善404页面,非合法路由自动跳转404

This commit is contained in:
jiayuqi7813
2022-06-29 01:49:05 +08:00
parent 9c3643cf7e
commit 5f188c748e
5 changed files with 210 additions and 2 deletions

View File

@@ -50,6 +50,15 @@ const router = createRouter({
path:'/admin',
name:'Admin',
component: () => import('../views/admin/index.vue'),
},
{
path:'/404',
name:'NotFound',
component: () => import('../views/404.vue'),
},
{
path: '/:pathMatch(.*)',
redirect: '/404'
}
]
})

9
src/views/404.vue Normal file
View File

@@ -0,0 +1,9 @@
<template>
<div id="app">
<iframe src="../../public/404/404.html" scrolling="auto" frameborder="0" style="width: 100%;height: 100%;"></iframe>
</div>
</template>
<style>
html,body,#app {height: 100%;}
</style>