解决方法:
- 法一:重写规则
import VueRouter from "vue-router";
const [routerPush, routerReplace] = [VueRouter.prototype.push, VueRouter.prototype.replace];
VueRouter.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error => error);
};
VueRouter.prototype.replace = function replace(location) {
return routerReplace.call(this, location).catch(error => error);
};
- 法二:降级处理(3.1 以下)
cnpm i vue-router@3.0 -S