美文网首页Web前端之路
vue router: NavigationDuplicated

vue router: NavigationDuplicated

作者: 嘻哈章鱼小丸子 | 来源:发表于2020-12-04 11:18 被阅读0次
描述

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

error
解决办法,有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不选中问题

相关文章

网友评论

    本文标题:vue router: NavigationDuplicated

    本文链接:https://www.haomeiwen.com/subject/albbwktx.html