解决报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)

3,113 阅读1分钟

在做vue2项目时出现如下错误,页面空白且控制台出现如下错误: 报错内容: Uncaught TypeError: Cannot read properties of undefined (reading 'install')

解决办法:

出现该情况的原因是vue-router安装的版本太高,一般vue2的项目对应的版本是vue-router@3版本

①在控制台输入: cnpm install --save vue-router@3.5.3 重新安装vue-router即可解决