vue实现动态设置页面title


router/index.js

const router = new Router({
mode: 'history',
routes: [
{
path: '/index',
name: 'index',
component: Index,
meta:{
// 页面标题title
title: '首页'
}
},
{
path: '/content',
name: 'content',
component: Content,
meta:{
title: '内容'
}
}
]
})
export default router

 

main.js

router.beforeEach((to,from,next) => {
if(to.meta.title){
document.title = to.meta.title
}
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM