vue设置页面标题title
router.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
}
next()
})