第一種方法:
在路由的index.js文件中添加如下代碼:
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
第二種方法:
將vue-router的版本降到3.0
yarn add vue-router@3.0
兩種方法都可以解決報(bào)錯(cuò)的問題.