router.js 416 B

1234567891011121314151617
  1. import Vue from 'vue'
  2. export const EventBus = new Vue()
  3. export default ({ app }) => {
  4. // 前置路由守卫
  5. app.router.beforeEach((to, from, next) => {
  6. EventBus.$emit('beforeEach')
  7. next()
  8. })
  9. // 后置路由守卫
  10. app.router.afterEach((to, from) => {
  11. const whiteList = ['template-ross-activity-challenge']
  12. if (whiteList.indexOf(to.name) > -1) return
  13. EventBus.$emit('afterEach')
  14. })
  15. }