vue-router 跳轉同一頁面時控制檯會報錯
阿新 • • 發佈:2021-02-04
導言:今天寫vue的時候發現,跳轉同一頁面的時候會報錯,雖然不影響跳轉,但是作為一名怕麻煩的程式設計師,還是要解決的,不然專案經理可不管你,這有錯解決一下,所以還是先下手比較好。報錯如下:
NavigationDuplicated: Avoided redundant navigation to current location: “/capital/withdrawal”.
解決方法(router/index.js)檔案中貼上如下程式碼:
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err);
}
報錯解決…