問題
在做菜單跳轉功能時,發現如果多次點擊同一個項,發生重復跳轉就會報錯。
Avoided redundant navigation to current location...
解決
(1) 高版本 VueRouter 新加的報錯信息,第一種辦法是減低 VueRouter 的版本。
(2) 第二種辦法是:在router文件夾下的index.js中添加以下代碼:
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}