首先在路由里面加meta,定义title属性
{
path: 'hotspring',
name: 'hotspring',
meta:{
title:'温泉小镇'
},
component: () =>
import ('../components/hotSpring')
},
在路由全局守卫里面如下配置:
router.beforeEach((to,from,next)=>{
document.title=to.matched[0].meta.title
next()
})