在使用Vue.js中欣除,有時我們雙擊或者頻繁點擊路由鏈接時,瀏覽器的控制臺時常會報Uncaught (in promise)這樣的錯誤。截圖如下:
下面是我整理好的代碼闯袒,親測有效。
將代碼復(fù)制到main.js中
????import?Router?from?'vue-router'
????const?originalPush?=?Router.prototype.push
????Router.prototype.push?=?function?push(location)?{
????????return?originalPush.call(this,?location).catch(err?=>?err)
????}