首页 > 其他分享 >Component name “home“ should always be multi-word.eslintvue/multi-word-component-names

Component name “home“ should always be multi-word.eslintvue/multi-word-component-names

时间:2022-11-15 01:23:13浏览次数:52  
标签:multi vue eslintvue component names 组件 word

原文链接:https://blog.csdn.net/m0_67676064/article/details/126861235

vue刚创建完就报错Component name “home“ should always be multi-word.eslintvue/multi-word-component-names,原因是在组件命名的时候未按照 ESLint 的官方代码规范进行命名。

解决方法:

配置 .eslintrc.js文件
关闭命名规则
找到 .eslintrc.js 文件在 rules 里面加上这么一句

// 关闭名称校验
'vue/multi-word-component-names': "off"

module.exports = {

rules: {

// 关闭名称校验

"vue/multi-word-component-names": "off",

},

};

关闭之后还是会有错误

新手在组件命名的时候不够规范,根据官方风格指南,除了根组件(App.vue)外,自定义组件名称应该由多单词组成,防止和html标签冲突。
而最新的vue-cli创建的项目使用了最新的vue/cli-plugin-eslint插件,在vue/cli-plugin-eslint v7.20.0版本之后就引用了vue/multi-word-component-names规则,所以在编译的时候判定此次错误。

解决方案:
修改组件名为多个单词,使用大驼峰命名方式或者用“-”连接单词。
————————————————
版权声明:本文为CSDN博主「myh0904」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_67676064/article/details/126861235

标签:multi,vue,eslintvue,component,names,组件,word
From: https://www.cnblogs.com/stepforeward/p/16891113.html

相关文章