报错问题如下图所示:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210416163711510.png#pic_center)
原因: 这个错误是vue-router内部错误,导致导航跳转问题,往同一地址跳转时会报错的情况push和replace 都会导致这个情况的发生。
解决方法:
在路由器router里面的index.js里面加上下面这段代码就没事了。
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
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);
};
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);
};
代码加载的位置如下如所示:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210416164150320.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpMjIzNTY=,size_16,color_FFFFFF,t_70)