const originalPush = Router.prototype.push
console.log(originalPush)
/*
VueRouter.prototype.push = function push(location, onComplete, onAbort) {
var this$1 = this;
console.log("222", location, onComplete, onAbort, typeof Promise)
// $flow-disable-line
if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
return new Promise(function(resolve, reject) {
this$1.history.push(location, resolve, reject);
}
)
} else {
this.history.push(location, onComplete, onAbort);
}
}
*/
Router.prototype.push = function push(location) {
// 重复push同一个路由,捕捉错误,不做处理
// Avoided redundant navigation to current location: "/login"
return originalPush.call(this, location).catch(err => {
// console.log("err", err)
return err
})
}
重复push同一个路由
于 2022-03-01 10:19:10 首次发布