在使用Vue.js中,有时我们双击或者频繁点击路由链接时,浏览器的控制台时常会报Uncaught (in promise)这样的错误。截图如下:
下面是我整理好的代码,亲测有效。
将代码复制到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)
}