我们在用vue脚手架vue-cli的时候,有时会出现这个错误。
我们的结果确实出来了没受影响,但是控制台还是报错,作为程序员,红色是不能忍的,所以!
怎么解决呢,我们只需要在router文件夹下的index.js引入下面内容即可
const originalPush = VueRouter.prototype.push
//push的解决方法
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
//replace的解决方法
VueRouter.prototype.replace = function replace (location) {
return originalPush.call(this, location).catch(err => err)
}