soybean-admin/doc/命名规范.md
2021-11-08 06:10:49 +08:00

56 lines
1.9 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.

### 驼峰式命名法:
**Pascal Case大驼峰式命名法**
首字母大写。egStudentInfo、UserInfo、ProductInfo
**Camel Case 小驼峰式命名法:**
首字母小写。egstudentInfo、userInfo、productInfo
### 文件、文件夹命名:
1. 文件夹作为**页面**时用小写字母,包含多个单词时,单词之间建议使用半角的连词线 ( - ) 分隔。
2. 文件夹作为**组件**时用大写驼峰命名。
3. 文件作为**组件**时用大写驼峰命名。
4. 文件作为**use函数**时用小驼峰命名。
5. 其余文件用小写字母,包含多个单词时,单词之间建议使用半角的连词线 ( - ) 分隔。
### 变量命名:
#### 命名方式 : 小驼峰式命名方法
**命名规范 : 类型+对象描述的方式,如果没有明确的类型,就可以使前缀为名词**
动词 | 含义 | 返回值
---|---|---
can | 判断是否可执行某个动作 | 函数返回一个布尔值。true可执行false不可执行。
has | 判断是否含有某个值 | 函数返回一个布尔值。true含有此值false不含有此值。
is | 判断是否为某个值 | 函数返回一个布尔值。true为某个值false不为某个值。
get | 获取某个值 | 函数返回一个非布尔值。
set | 设置某个值 | 无返回值、返回是否设置成功或者返回链式对象。
- 推荐:
```javascript
//是否可读
function canRead(){
return true;
}
//获取姓名
function getName(){
return this.name;
}
```
### 常量
#### 命名方法 : 全部大写
**命名规范 : 使用大写字母和下划线来组合命名,下划线用以分割单词。**
- 推荐:
```javascript
const MAX_COUNT = 10;
const URL = 'http://www.baidu.com';
```
### TS类型
命名统一使用大写驼峰
interface和type使用优先级能用interface表示的类型就用interface。