欢迎使用皮肤 Geek|

xuelin

园龄:3年粉丝:1关注:4

若依、vue三级路由缓存失败

router.beforeEach((to, from, next) => {
  NProgress.start()
  if (getToken()) {
    // 三级菜单组件无法缓存问题
    if (to.matched && to.matched.length > 2) {
      to.matched.splice(1, to.matched.length - 2)
    }
   
    to.meta.title && useSettingsStore().setTitle(to.meta.title)
   
    } else {
      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
      NProgress.done()
    }
  }
})

本文作者:xuelin

本文链接:https://www.cnblogs.com/xuelinomen/p/17943286

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   xuelin  阅读(148)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起