router-interceptor.js 350 B

123456789101112131415
  1. /**
  2. * 404 页面拦截
  3. * @param router
  4. */
  5. export function interceptorNotFindPage (router) {
  6. router.beforeEach(async (to, from, next) => {
  7. const canNext = to.name || to.path.includes(this.route.base)
  8. this.log('interceptorNotFindPage canNext', canNext)
  9. if (canNext) {
  10. next()
  11. } else {
  12. next(this.route[404])
  13. }
  14. })
  15. }