路由文件 :router/index.js
import Vue from ‘vue‘
import Router from ‘vue-router‘
import index ‘@/view/index‘
import user from ‘@/view/user‘
Vue.use(Router)
export default new Router({
routes: [
{
path: ‘/index‘,
name: ‘index‘,
component: index,
meta:{
title:‘首页‘
}
},
{
path: ‘/user‘,
name: ‘user‘,
component: user,
meta:{
title:‘个人中心‘
}
}
]
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
在入口文件 main.js中添加以下代码
import Vue from ‘vue‘
import App from ‘./App‘
import router from ‘./router‘
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
next()
})
new Vue({
el: ‘#app‘,
router,
template: ‘<App/>‘,
components: {App}
})
---------------------
作者:、不知不觉、
来源:CSDN
原文:https://blog.csdn.net/u010394015/article/details/79132591
版权声明:本文为博主原创文章,转载请附上博文链接!
原文地址:https://www.cnblogs.com/itgezhu/p/10884467.html