美文网首页奇思妙想Vue
Vue 动态设置路由Meta title 名称

Vue 动态设置路由Meta title 名称

作者: 小小Bug你别跑 | 来源:发表于2022-06-07 11:50 被阅读0次

路由配置

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:'动态路由名称'
    }
})

都可以,看着用。随堂笔记防遗忘!

相关文章

网友评论

    本文标题:Vue 动态设置路由Meta title 名称

    本文链接:https://www.haomeiwen.com/subject/cucemrtx.html