解决报错: error Component name “List“ should always be multi-word vue/multi-word-component-names

报错情况:

 ERROR  Failed to compile with 1 error                                                                                  
[eslint]
E:\project\github\github\src\components\List.vue
  38:10  error  Component name "List" should always be multi-word  vue/multi-word-component-names

E:\project\github\github\src\components\Search.vue
  12:10  error  Component name "Search" should always be multi-word  vue/multi-word-component-names

✖ 2 problems (2 errors, 0 warnings)

报错如图:

 出现该错误的原因是eslint的语法检查,组件的命名不合eslint的规范。

解决方法1:

修改vue.config.js里的配置:增加一个配置项:lintOnSave:false

const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({

  transpileDependencies: true,

  lintOnSave:false

})

 如图:

解决方法2:将命名以 驼峰命名 的方式进行重新命名

这个错误是由Vue3编译器产生的,错误信息是"Component name 'index' should always be multi-word vue/multi-word-component-names"。这个错误是因为Vue官方建议除了App.vue组件外,自定义组件的名称应该由多个单词组成,最好使用驼峰命名法。而在你的代码中,使用了单个单词命名组件,所以编译器会报出这个错误提示。为了解决这个问题,你可以在根目录下的package.json文件中找到eslintConfig配置,然后添加如下规则配置:"rules": { "vue/multi-word-component-names":"off" }。这样做是告诉eslint不再检测组件名称是否为多个单词,从而避免这个错误的出现。另外,你也可以在根目录下新增一个vue.config.js文件,并在其中配置lintOnSave为false,来关闭eslint的校验。这样也可以解决这个错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [解决报错error Component name “index“ should always be multi-word vue/multi-word-component-names](https://blog.csdn.net/weixin_51551506/article/details/126965116)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [eslint:vue报错 error Component name ““ should always be multi-word](https://blog.csdn.net/weixin_45866961/article/details/129450935)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

女码农୧( ⁼̴̶̤̀ω⁼̴̶̤́ )૭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值