Uncaught (in promise) Error: Navigation cancelled from "/" to "/home" with a new navigation. at createRouterError

vue报了以下报错:

 

原因:未知,能解决就行(。。。。)

 

在router的index.js中插入以下代码解决:

const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
//push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
//replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
    if (onResolve || onReject)
        return originalReplace.call(this, location, onResolve, onReject);
    return originalReplace.call(this, location).catch(err => err);
};

 

posted @ 2022-06-10 03:01  莫得感情的肝帝  阅读(1821)  评论(0编辑  收藏  举报