-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a627216
commit bf32a5a
Showing
5 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,41 @@ | |
|
||
### 默认 mock 类型 | ||
|
||
| 类型 | 默认值 `mock` 值 | 解释 | 实例 | | ||
| 类型 | 默认值 `mock` 值 | 解释 | 示例 | | ||
| --- | --- | --- | --- | | ||
| string | @csentence | 一般字符串 | "白高长正深常究厂影常小际么知影证。" | | ||
| number | @integer(1, 10000) | 一般数字 | 729 | | ||
| boolean | @boolean | 布尔值 | true | | ||
| array.length | @integer(0, 50) | 数组的长度 | 38 | | ||
| // | @datetime | 符合正则的时间类型 | "2014-02-18 20:33:40" | | ||
| `string` | `@csentence` | 一般字符串 | "白高长正深常究厂影常小际么知影证。" | | ||
| `number` | `@integer(1, 10000)` | 一般数字 | 729 | | ||
| `boolean` | `@boolean` | 布尔值 | `true` | | ||
| `array.length` | `@integer(0, 50)` | 数组的长度 | 38 | | ||
| `/\w*(?:[dD]ate)|(?:[tT]ime)\w*/` | @datetime | 符合正则的时间类型 | "2014-02-18 20:33:40" | | ||
| `/\w*[iI]d$/` | `@increment` | 符合正则的 `id`,保证 `id` 不重复 | "2014-02-18 20:33:40" | | ||
| `/\w*[Nn]ame$/` | `@cname` | name | | ||
| `/^province(?:Name)?$/` | `@province` | 省份 | | ||
| `/^city(?:Name)?$/` | `@city` | 城市 | | ||
| `/\w*[pP]ics?|\w*[pP]ictures?|\w*[iI]mgs?|\w*[iI]mages?/` | `@image` | 图片 | | ||
| `/\w*[cC]ode$/` | `@string("lower", 5)` | code | | ||
| `/\w*[pP]hone(?:Number)?/` | `{"regexp": "\\d{11}"}` | 手机号 | | ||
|
||
### 常用 mock 类型 | ||
|
||
默认的 `mock` 类型不可能在所有场景都能很好使用,这里列举常用的 `mock` 类型: | ||
|
||
| mock | 解释 | 返回示例 | | ||
| --- | --- | --- | | ||
| `@pick(["a", "e", "i", "o", "u"])` | 在一个枚举值中随机挑选一个值,常用语**状态**之类的字段 | `e` | | ||
| `@region` | 返回一个区域 | 华北 | | ||
| `@province` | 返回一个省份 | 河北省 | | ||
| `@city` | 返回一个城市 | 菏泽市 | | ||
| `@city(true)` | 返回一个带省份的城市 | 浙江省 宁波市 | | ||
| `@county` | 返回一个区、县 | 长宁区 | | ||
| `@city(true)` | 返回完整的区县 | 北京 北京市 海淀区 | | ||
| `@email` | 返回随机邮箱 | [email protected] | | ||
| `@url` | 返回随机 `url` 地址 | "http://nscgpruo.su/plfjwr" | | ||
| `@cname` | 返回随机中文姓名 | 康艳 | | ||
| `@cword( pool?, min?, max? )` | 返回限定的随机长度的随机中文字符 | 在院门 | | ||
| `@cparagraph( min?, max? )` | 返回限定的随机长度的中文段落 | 构标号住石见关包往再声亲严证千度真。五增上已每法流确京北改开总农圆。如群省志然料且史好比物质达低长天门。第里中型研装果其内等土调号了存机见七。查已问回江员求子育属世式土党速。| | ||
| `@image( size?, background?, foreground?, format?, text? )` | 返回一个图片地址 | "http://dummyimage.com/200x100/FF6600" | | ||
| `@id` | 生成一个身份证号 | 360000201905197112 | | ||
|
||
### 覆盖默认 mock 数据 | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters