1.router目录下的index.js
2.main.js
router.beforeEach((to,from,next)=>{
if(to.meta.root) {
if(token) {
next();
}else{
console.log('请先登录')
}
}else{
next();
}
})
3.main.js设置网站title
router.beforeEach((to, from, next) => {
//路由发生改变时,触发
window.document.title = to.meta.title == undefined ? 'xxx' : 'xxx-'+to.meta.title;
next();
})
网友评论