Uncaught (in promise) Error: Avo

2020-08-06  本文已影响0人  爱的旋转体
  • vue路由报错:
    Uncaught (in promise) Error: Avoided redundant navigation to current location
  • 原因:
    多次点击跳转同一个路由是不被允许的
  • 解决办法:
    在引入vue-router的js文件里加上如下代码即可:
//push 
const VueRouterPush = Router.prototype.push 
Router.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

//replace
const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace (to) {
  return VueRouterReplace.call(this, to).catch(err => err)
}

参考:https://blog.csdn.net/qq_30071415/article/details/106334953

上一篇 下一篇

猜你喜欢

热点阅读