在工作中遇到了这个问题,当路由跳转到相同的地址的时候,控制台会报这个错误:

方法一:
安装vue-router3.0以下版本:先卸载3.0以上版本然后再安装旧版本:
npm install @vue-router2.8.0 -S
方法二:
针对于路由跳转相同的地址添加catch捕获以下异常:
this.$router.push('/location').catch(err => {console.log(err)})
方法三:
在main.js下注册一个全局函数即可:
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}