Vue 动态设置路由Meta title 名称
2022-06-07 本文已影响0人
小小Bug你别跑
路由配置
import ('@/views/accountManagement/editMain'),
beforeEnter: (to, from, next) => {
if (to.query.id == 1) {
to.meta.title = '编辑主账号'
} else {
to.meta.title = '编辑子账号'
}
next()
},
路由跳转
this.$router.push({
path: 'editMain',
query: {
id: 1||2
}
})
或路由配置
import ('@/views/accountManagement/editMain'),
beforeEnter: (to, from, next) => {
to.meta.title = to.query.titleName
next()
},
路由跳转
this.$router.push({
path: 'editMain',
query: {
titleName:'动态路由名称'
}
})
都可以,看着用。随堂笔记防遗忘!