- 原因
重复的路由跳转
当前路由'/index',
调用编程式路由方法$router.push({path:'/index'}),即跳转路由和当前路由一致
- 解决方法
修改VueRouter原型对象上的push方法
//获取原型对象上的push函数 const originalPush = Router.prototype.push; //修改原型对象中的push方法 Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) }; Vue.use(Router);