最近項目開發過程中遇到了重復點擊路由會出現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 }