首页 > 其他 > 详细

vue动态改变每个表头的方法

时间:2018-11-16 14:27:42      阅读:620      评论:0      收藏:0      [点我收藏+]

第一步:router里边设置每一个页面的标头

{
path: ‘/‘,
name: ‘Home‘,
component: Home,
meta: {
keepAlive: false, // 页面缓存字段
title: ‘首页‘
}
},
{
path: ‘/Login‘,
name: ‘Login‘,
component: Login,
meta: {
title: ‘登录注册‘
}
},
{
path: ‘/BBSData‘,
name: ‘BBSData‘,
component: BBSData,
meta: {
title: ‘论坛资料‘
}
},
第二步在main.js里边添加下边的代码
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面meta */
if (to.meta.content) {
let head = document.getElementsByTagName(‘head‘)
let meta = document.createElement(‘meta‘)
meta.content = to.meta.content
head[0].appendChild(meta)
}
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title
}
next()
})

 

vue动态改变每个表头的方法

原文:https://www.cnblogs.com/nuoo/p/9969030.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!