vue-router设置页面标题

通过vue-router设置页面标题

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'EntryConfirmation',
      meta: { title: "到岗候选人名单确认" },
      component: EntryConfirmation
    }
  ]
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {//如果设置标题,拦截后设置标题
    document.title = to.meta.title
  }
  next()
})

export default router
原文地址:https://www.cnblogs.com/mybky/p/7683475.html