当前位置: 代码迷 >> 综合 >> 报错:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “
  详细解决方案

报错:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “

热度:69   发布时间:2023-11-24 00:21:40.0

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/cart报错

解决办法:在router下index.js中加入下面代码

1. replace

const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err);
};

2. push

const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err);
}
  相关解决方案