0
点赞
收藏
分享

微信扫一扫

vue router: NavigationDuplicated: Avoided redundant navigation to current location: "/template"

在觉 2021-09-24 阅读 67
描述

element-ui多次点击导航(多次push同一个路由),会报错:

解决办法,有2种
  • use router之前加入如下代码
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
  • 不使用router 模式,在select中加判断
 handleSelect(key, keyPath) {
      if (key === this.$route.path) {
        return;
      }
      //一些处理
}
参考:

关于element-ui navMenu不选中问题

举报

相关推荐

0 条评论