在vue项目中,如果使用$router.push跳转到一个相同的路由会报错如何解决
vue-router在3.1.0版本之后,push和replace方法会返回一个promise对象,如果跳转到相同的路由,就报promise uncaught异常
1.可以回退版本
2.在router/index.js导入VueRouter的时候,进行全局的处理再main.js中
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}