一、router文件夹下的index文件中给每个path添加meta:{}:
export default new Router({
routes: [
{
path: ‘/‘,
name: ‘index‘,
component: index,
meta: {
title: ‘title1‘
}
},
{
path: ‘/studentInfo‘,
name: ‘studentInfo‘,
component: studentInfo,
meta: {
title: ‘title2‘
}
}
]
})
二、js入口文件main.js中添加代码:
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title
}
next()
})
---------------------
作者:web_xyk
来源:CSDN
原文:https://blog.csdn.net/web_xyk/article/details/80451561
版权声明:本文为博主原创文章,转载请附上博文链接!
原文地址:https://www.cnblogs.com/mengyage/p/10558605.html
时间: 2024-11-09 02:13:37