很好奇在ESlint规范中为啥要求component的name不能是单个单词(除了App外)呢?
查阅官方文档得知:
This rule require component names to be always multi-word, except for root App components, and built-in components provided by Vue, such as or . This prevents conflicts with existing and future HTML elements, since all HTML elements are a single word.
简单来说,就是为了防止与之后的html标签冲突,因为html标签都是单个单词的。所有推荐采用multi-word,确实如此。
而且还有一个好处是:在html中调用的形式为<home-page />
,如果统一采用此规则,可以一眼看出那些标签是自己定义的组件,缺点自然就是命名得琢磨一番了