1.把项目依赖的 node_modules 文件夹删除, 然后再 npm install 重新下载依赖包就可以解决。
2.如果在重新下载依赖包时,安装的vue-router还是之前出错的那个版本,那么要怎么解决呢?解决方法也很简单,在项目目录下运行 npm i vue-router@3.0 -S即可
3.可以在router.js 的配置文件里下添加一下代码(在use之前):
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}