vue路由跳轉更改頁面title


1.在路由數組設置里加meta對象

const routes = [
    { path: '/workReport',
      component: WorkReport,
      meta: {
          title: '往期日報'
      }
    }
]

const router = new VueRouter({
    routes
})

2.做如下配置

router.beforeEach((to, from, next) => {
    /* 路由發生變化修改頁面title */
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM