error Component name “Hello“ should always be multi-word vue/multi-word-component-names

前言

使用vue-cli创建Vue项目

环境

  • node -v: v16.15.1
  • npm -v: 8.11.0
  • 其他包版本:
    @babel/eslint-parser@7.19.1
    @vue/cli-plugin-eslint@5.0.8
    eslint-plugin-vue@8.7.1
    eslint@7.32.0
    vue@2.7.13

报错信息

1:1  error  Component name "Hello" should always be multi-word  vue/multi-word-component-names

报错原因

eslint-plugin-vue 版本更新到@8,相较之前版本,@8 版本中新增了不少规则,其中要求组件名称以驼峰格式命名

// node_modules\eslint-plugin-vue\lib\configs\vue3-essential.js
  ...
  rules: {
    'vue/multi-word-component-names': 'error',
    ...
  }
  ...

解决办法

  • 方法一:遵守规则
    将组件名改为驼峰格式命名,如hello 改为 helloHello
  • 方法二:关闭规则,编辑项目根目录下的vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,    // 新增代码
})
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值