vue导航守卫修改标题

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})

router.beforeEach((to, from, next) => {
  console.log("beforeEach");
  console.log(from);
  console.log(to);
  document.title = to.matched[0].name;
  next();
})

标题修改

posted @ 2021-07-09 14:32  thomas_blog  阅读(102)  评论(0编辑  收藏  举报