Uncaught (in promise) Error: Avoided redundant navigation to current location

  • 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)
}


 

猜你喜欢

转载自blog.csdn.net/ljy_1024/article/details/110791601