一、在router/index.js加以下代码
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return routerPush.call(this, location).catch(err => err)
}
二、找到跳转引起报错的地方,加catch
这个console.log可以啥也不打印,但是必须得写,否则无效
router.replace('/').catch(err => {
console.log();
})