先上报错
![](https://img-blog.csdnimg.cn/direct/21db2b1d04cc4342a54870ce4ac5fd98.png)
解决方案:
![](https://img-blog.csdnimg.cn/direct/ef4de2972e27455aa42442d30a229f59.png)
javascript
//1:缓存原始的plus.push
const originalPush = VueRouter.prototype.push;
//2:增强plus.push.
VueRouter.prototype.push = function(location, okCallBack, errCallBack) {
//没有成功,失败的回调, 那就使用catch
if (okCallBack === undefined && errCallBack === undefined) {
return originalPush.call(this, location).catch(() => {});
} else {
//如果有了成功,失败的回调,那就使用传过来的成功跟回调
return originalPush.call(this, location, okCallBack, errCallBack).catch(() => {});
}
}