在注册路由器之前,重写原型对象的方法
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
const originaReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return originaReplace.call(this, location).catch(err => err)
}
完美解决连续点同一个路径 报错 ,原理就是catch了