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>
转载于:https://blog.51cto.com/4547985/2390808