vue项目运行时报错整理1

在使用vue-cli创建项目并尝试运行时遇到错误,包括Vue组件的语法错误、依赖未找到的问题以及<router-link>元素未注册的提示。解决方法分别涉及更新vue-loader和style-loader的版本、检查webpack配置以及确保正确引入路由组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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!!!(重要事情说三遍)



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值