1、mode模式
代碼示例:
export default new Router({ mode: 'history', //mode模式 routes: [...]})
mode取值說明:
(1)histroy:URL就像正常的 url,示例:http://localhost:8080/home
(2)hash:默認值,會多一個“#”,示例:http://localhost:8080/#/home
2、404頁面設置
如果訪問的路由不存在,或者用戶輸入錯誤時,會有一個404友好的提示頁面,配置如下:
(1)在/src/router/index.js中加入如下代碼:
// 404{ path: '*', component: () => import('@/components/404')}
(2)在src/components/404.vue中編寫如下代碼:
<template> <div class="hello"> <h1>404 not found</h1> </div></template><script>export default { data () { return { } }}</script><style scoped></style>