dev-aid/CodeConventions.md
2023-04-21 10:59:32 +08:00

53 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 align="center">编码规范、代码风格</h1>
### Pascal CasePascal 大驼峰式命名法
例如UserInfo, UserName
### Camel Case小驼峰式命名法
例如userInfo, userName
## 前端
### HTML
- 标签名必须使用小写字母,标签使用要遵循其语义
- 标签属性名必须使用小写字母,属性必须用双引号("")包围,自定义属性以 data- 作为前缀
- bool 类型的属性不需要添加属性值
- class 必须单词全字母小写,单词之间以 '-' 分隔
- id 必须保证同一个页面内唯一使用小驼峰式命名camelCase
-
### CSS
### JavaScript
- 变量名使用小驼峰式命名camelCase
- 函数名使用小驼峰式命名camelCase
- 函数名称一般以动词+名字的形式命名,例如 getUserInfo(), initData(), loadTableData()
- 事件名称一般以名词+handle 的形式命名,例如 editHandle, selectedHandle
- 查询前缀一般添加 get新增前缀一般加 add 或者 create更新前缀一般添加 update 或者 edit删除前缀一般添加 delete 或者 remove
- 文件名使用小驼峰式命名camelCase
### TypeScript
## 服务端
### C#
- 类名、文件名使用 Pascal 式命名
## 工作目录
磁盘根目录创建 Workspace 目录,目录结构示例:
- docs # 项目文档根目录
- 平安电器物联网平台 # 项目名称
- repos # 项目代码仓库根目录
- pingan-iot # 项目名称
- pingan-iot-api 后端服务项目目录,和 git 服务器上的名称一致
- pingan-iot-admin 管理后台前端项目根目录,和 git 服务器上的名称一致
- smart-venue # 另一个项目名称
- smart-venue-mp # 微信小程序端项目根目录,和 git 服务器上的名称一致