动态改变每个页面标题,通过路由发现变化时改变标题名称
1、在main.js下加入如下代码:
// 动态标题
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title
}
next()
})2、在路由文件,index.js下加入如下代码:meta:{ title: '名称 '}
const routes = [
{
path: '/home',
component: Home,
redirect: '/wecome',
children: [
{ path: '/wecome', component: Wecome, meta:{ title: 'VuePro-主页'}},
{ path: '/user', component: User , meta:{ title: 'VuePro - 管理员管理'}},
]
}
]
关于简忆
简忆诞生的故事



粤ICP备16092285号
文章评论(0)