router文件中的index.js:
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title || 'title';
}
next();
});
在配置路由时添加meta对象,在其中加入title属性
{
path: '/a',
name: 'a',
component: () => import('./a'),
meta: {
title: 'a-b'
// a-b就是该页面的标题
}
}