我们在用vue-router 做单页应用的时候重复点击一个跳转的路由会出现报错,简称路由重复,如下图:
上图的报错就是重复路由引起的,如何解决vue-router报Avoided redundant navigation to current location 路由重复错误呢?
只需在注册路由组建后重写路由就可以,具体代码如下:
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题 const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location:any) { return originalPush.call(this, location).catch((err:any) => err) }
本文地址:http://kf.yj99.vip/zhan/q/29.html