打开http://localhost:8080/,控制台报错
Uncaught TypeError: Object(...) is not a functionat eval (vue-router.esm-bundler.js?f2fc:2127:1)at Object../node_modules/vue-router/dist/vue-router.esm-bundler.js (app.js:2218:1)at __webpack_require__ (app.js:679:30)at fn (app.js:89:20)at eval (index.js?3672:1:1)at Object../src/router/index.js (app.js:2358:1)at __webpack_require__ (app.js:679:30)at fn (app.js:89:20)at eval (main.js?1c90:1:1)at Object../src/main.js (app.js:2350:1)
cmd运行npm run dev
没有报错,但也没有显示成功
看了好多篇文章,找了好几天的错,也没有找到解决方法,都不管用,找的心累了,这不终于整好了
【解决办法】: 降低vue-router版本
因为vue-router版本过高,所以报错(我的默认版本是4.0.14的版本)
"dependencies": {"element-ui": "^2.15.6","vue": "^2.5.2"},"devDependencies": {"node-sass": "^7.0.1","sass-loader": "^12.6.0","vue-loader": "^13.3.0","vue-router": "^4.0.14",}
1、package.json中修改vue-router版本,然后再npm install下
2、或者在cmd输入
npm install vue-router@3.5.3
再运行npm run dev
,成功了