1.修改router中index.js文件中每个路由加上meta:{ title: ‘首页’}
const router = new Router({
mode: '',
routes: [
{
path: '/',
name: '',
component: ,
meta:{
//
title: '首页'
}
}
]
})
2.main.js中加上
import router from './router'
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title
}
next()
})