# 路由模式与 404
# 路由模式
路由模式有两种
- hash:路径带
#
符号,如http://localhost/#/login
- history:路径不带
#
符号,如http://localhost/login
修改路由配置,代码如下:
export default new Router({
mode: 'history',
routes: [
]
});
1
2
3
4
5
2
3
4
5
# 处理 404
创建一个名为 NotFound.vue
的视图组件,代码如下:
<template>
<div>
页面不存在,请重试!
</div>
</template>
<script>
export default {
name: "NotFount"
}
</script>
<style scoped>
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
修改路由配置,代码如下:
{
path: '*',
component: NotFound
}
1
2
3
4
2
3
4