problems
Uncaught runtime errors:
×
ERROR
Cannot read properties of undefined (reading ‘install’)
TypeError: Cannot read properties of undefined (reading ‘install’)
at Vue.use (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:5466:27)
at eval (webpack-internal:///./src/router.js:10:45)
at ./src/router.js (http://localhost:8080/js/app.js:230:1)
at webpack_require (http://localhost:8080/js/app.js:280:33)
at fn (http://localhost:8080/js/app.js:513:21)
at eval (webpack-internal:///./src/main.js:4:65)
at ./src/main.js (http://localhost:8080/js/app.js:219:1)
at webpack_require (http://localhost:8080/js/app.js:280:33)
at http://localhost:8080/js/app.js:1401:109
at webpack_require.O (http://localhost:8080/js/app.js:326:23)
*
*
通过查询,是因为vue-router安装的版本过高
// vue 版本和 vue-router 版本不匹配
vue&&vue-router版本不匹配
版本vue@2.7.14而vue-router@4.2.2
安装 vue-router 时,直接运行了 npm install vue-router 命令,造成直接下载最新版 vue-router @4.2.2
而 4 以后的版本适用于 vue@3.0 版本,用在 vue@2.x会报错。
解决
在项目录下,打开cmd
命令行,先卸载最新的vue-router;然后,再去下载vue-router@3.x版本
npm uninstall vue-router
npm install -g vue-router@3.x
or
npm install vue-router@3 --save