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

来源:简书 分类: 文章浏览史 发布时间:2021-09-12 11:58:07 最后更新:2021-09-12 浏览:320
转载声明:
本文为摘录自“简书”,版权归原作者所有。
温馨提示:
为了更好的体验,请点击原文链接进行浏览
摘录时间:
2021-09-12 11:58:07
  • 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

php技术微信