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

在做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‘)_第1张图片

 解决报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)_第2张图片

解决办法:

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

①在控制台输入: cnpm install --save [email protected] 重新安装vue-router即可解决

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

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

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

你可能感兴趣的:(前端bug,vue.js,前端,bug)