router/index.js上
// const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onComplete, onAbort) {
let $that = this
if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
return new Promise(function(resolve, reject) {
$that.history.push(location, resolve, reject)
}).catch(err => {
//err 有时为undefined 不好打印err.message 直接打印err就会出现红色报错,气死强迫症
//console.log('router push error:', err)
//console.log('router push error:', err.message)
})
} else {
$that.history.push(location, onComplete, onAbort)
}
}