报错
vue2脚手架运行npm run dev,失败,报这样的错
vue-router.esm-bundler.js?6c02:2127 Uncaught TypeError: Object(...) is not a functionat eval (vue-router.esm-bundler.js?6c02:2127:1)at Module../node_modules/vue-router/dist/vue-router.esm-bundler.js (app.js:2489:1)at __webpack_require__ (app.js:724:30)at fn (app.js:101:20)at eval (index.js?a18c:1:1)at Module../src/router/index.js (app.js:2936:1)at __webpack_require__ (app.js:724:30)at fn (app.js:101:20)at eval (main.js:12:74)at Module../src/main.js (app.js:2924:1)
原因及解决方案
package.json中查看vue-router版本
由于项目是vue2,安装的vue-router的版本太高了,当前版本 “vue-router”: “^4.0.15”, 降低版本就可以
指定vue-router版本,重新安装vue-router
npm install vue-router@3.5.3