beforeEach

router.beforeEach((to, from, next) => {

  let path = to.path.split('/').pop()
  if (obj[path]) {
    document.title = obj[path]
    next()
  }
  // 跳转到其他暂无数据页面 next()不会唤起beforeEach狗子函数,而next(params)这样会重新唤起beforeEach钩子函数 这样就有可能造成无线循环
  else {
    if (to.path === '/no-data') next()
    else next({
      name: 'noData'
    })

  }
})

 

posted on 2020-10-19 13:02  章画  阅读(237)  评论(0编辑  收藏  举报

导航