// 定义路由
{
path: '/sign-up',
name: 'SignUp',
component: () => import('@/views/signUp/SignUp'),
meta: { title: '报名页面', keepAlive: false }
},
{
path: '/signup-success',
name: 'SignUpSuccess',
component: () => import('@/views/signUp/SignUpSuccess'),
meta: { title: '报名成功', keepAlive: false }
}
// 在main.js 中添加
router.afterEach((to, from) => {
if (to.meta.title || to.query.title) {
const title = to.query.title || to.meta.title
document.title = title
}
})
// 也可以在页面的生命周期中使用
document.title = 'XXX'
个人学习笔记