标签:before rip word selector document title setattr router key
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title
}
if(to.meta.content){
let head = document.getElementsByTagName(‘head‘);
let meta = document.createElement(‘meta‘);
document.querySelector(‘meta[name="keywords"]‘).setAttribute(‘content‘, to.meta.content.keywords)
document.querySelector(‘meta[name="description"]‘).setAttribute(‘content‘, to.meta.content.description)
meta.content = to.meta.content;
head[0].appendChild(meta)
}
next()
})
vue 单页面 keywords description title
标签:before rip word selector document title setattr router key
原文地址:https://www.cnblogs.com/mrt-yyy/p/14470007.html