在做vue2项目时出现如下错误,页面空白且控制台出现如下错误:

报错内容:

Uncaught TypeError: Cannot read properties of undefined (reading 'install')
    at Vue.use (vue.runtime.esm.js?c320:5709:1)
    at eval (index.js?5aa4:7:1)
    at ./src/router/index.js (app.js:491:1)
    at __webpack_require__ (app.js:584:33)
    at fn (app.js:818:21)
    at eval (main.js:4:65)
    at ./src/main.js (app.js:480:1)
    at __webpack_require__ (app.js:584:33)
    at app.js:1706:109
    at __webpack_require__.O (app.js:630:23)

报错图片:

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

 解决报错: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即可解决

如果没有安装cnpm命令的,可以先安装:cnpm install

②如果安装了cnpm 命令,则在控制台输入: cnpm install --save vue-router@3.5.3 重新安装vue-router即可解决

③没有cnpm命令 也可 则在控制台输入: npm install --save vue-router@3.5.3 重新安装vue-router即可解决

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。