vue-cli刚搭建好项目,运行时报错
1、项目下面报错
error in ./src/components/Hello.vue
Syntax Error: Unexpected token {
@ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"id":"data-v-53cf4260","scoped":true,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./s
rc/components/Hello.vue 4:14-313 13:3-17:5 14:22-321
@ ./src/components/Hello.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
解决办法:
修改package.json:
"vue-loader":
"11.1.4",
"style-loader": "^0.13.2",
2、找不到依赖,并让你安装报错如下:
This dependency was not found:
* common/stylus/index.styl in ./src/main.js
To install it, you can run : npm install --save common/stylus/index.styl
> Listening at http://localhost:8080
解决办法:其实它并不是一个node模块
build目录下的webpack.base.conf.js文件中如下设置即可
resolve: { extensions: ['.js', '.vue', '.json'], alias: { 'vue$': 'vue/dist/vue.esm.js', '@': resolve('src'), 'common': resolve('src/common') } },
3、控制台报错如下:
Unknown custom element: <router-link> - did you register the component corre
解决办法:没有引入router!!!没有引入router!!!没有引入router!!!(重要事情说三遍)
在使用vue-cli创建项目并尝试运行时遇到错误,包括Vue组件的语法错误、依赖未找到的问题以及<router-link>元素未注册的提示。解决方法分别涉及更新vue-loader和style-loader的版本、检查webpack配置以及确保正确引入路由组件。

被折叠的 条评论
为什么被折叠?



