vue处理路由重复的问题

最近项目开发过程中遇到了重复点击路由会出现NavigationDuplicated: Avoided redundant navigation to current location: "/login"这个问题,重复触发了路由导航。

这是由于vue-router版本更新之后出现的问题,在router目录下的index的文件中添加如下代码可以解决该问题。

1 import Router from "vue-router"
2 Vue.use(Router)
3 const originalPush = Router.prototype.push
4    Router.prototype.push = function push(location) {
5    return originalPush.call(this, location).catch(err => err)
6 }

 

posted @ 2020-10-13 10:36  Silvia1108  阅读(1372)  评论(0)    收藏  举报