且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular的大小写风格规范

更新时间:2022-09-10 17:42:18

官网地址:https://angular.io/guide/glossary


Case types

camelCase: Symbols, properties, methods, pipe names, non-component directive selectors, constants. Standard or lower camel case uses lowercase on the first letter of the item. For example, “selectedHero”. 首字母必须小写。

参考下图高亮的例子:


Angular的大小写风格规范

UpperCamelCase (or PascalCase): Class names, including classes that define components, interfaces, NgModules, directives, and pipes, Upper camel case uses uppercase on the first letter of the item. For example, “HeroListComponent”.

参考下图高亮的例子:

Angular的大小写风格规范

  • dash-case (or “kebab-case”): 用于定义文件名,以及selector:

Angular的大小写风格规范

underscore_case (or “snake_case”): 例如"convert_link_mode". 在Angular中不常用。


UPPER_UNDERSCORE_CASE (or UPPER_SNAKE_CASE, or SCREAMING_SNAKE_CASE): 用于定义常量。