在 Router / index.js (路由配置文件) 中:
/* 1. 备份push方法 */
let originPush = VueRouter.prototype.push
console.log(originPush);
/* 2. 重写push方法 */
/*
location:跳转地址,传递的参数
resolve:成功时回调
reject:失败时回调
*/
VueRouter.prototype.push = function (location, resolve, reject) {
if (resolve && reject) {
originPush.call(this, location, resolve, reject)
} else {
originPush.call(this, location, () => {}, () => {})
}
}