Vue-touter的全局守卫的使用,设置页面的动态标题
1.在router的index.js配置映射关系中添加meta:{title:'首页'};
{
path:'/profile',
component:Profile,
meta:{
title:'个人'
}
2、使用 router.beforeEach方法:
router.beforeEach( (to,from,next) => {
document.title = to.matched[0].meta.title
next();
})

浙公网安备 33010602011771号