useMock

Extend 扩展

注意:扩展语法使Mock数据更贴近真实环境输出,后期将不断补充,感谢关注..

您可以复制以下语法到Mock模拟器中体验

@newsTitle 更真实的标题

语法

{
  "newsTitle-1": "@newsTitle",
  "newsTitle-2": "@newsTitle()",
  "newsTitle-3": "@newsTitle('en')",//英文
}

运行结果

{
  "newsTitle-1": "广州市金融局:将对北交所上市企业予补贴",
  "newsTitle-2": "在元宇宙的竞争中,谁在占据 C 位?",
  "newsTitle-3": "Another top official rips Rittenhouse verdict along with president, Harris"
}

@fruit 随机水果

语法

{
  "fruit-1": "@fruit",
  "fruit-2": "@fruit()",
  "fruit|3": "@fruit() "//混合Mock基础语法重复3次
}

运行结果

{
  "fruit-1": "芒果",
  "fruit-2": "西梅",
  "fruit": "草莓 柠檬 苹果 "
}

@brandDomain 国内品牌域名

语法

{
  "brandDomain-1": "@brandDomain",
  "brandDomain-2": "@brandDomain()"
}

运行结果

{
  "brandDomain-1": "qq.com",
  "brandDomain-2": "126.com"
}

Faker 用法说明

语法

{
  "locale": function({ Faker }) { //导入 Faker
    Faker.locale = "zh_CN" //设置语言, 目前中文支持的不太好 zh_CN/en/zh_TW ...
    return {
      "city":Faker.address.city(),//调用Faker方法
      "fake":Faker.fake("{{name.lastName}}, {{name.firstName}}")//调用Faker模板
    }
  }
}

运行结果

{
  "locale": {
    "city": "西 君浩沙市",
    "fake": "陈, 鸿煊"
  }
}
@faker-js 官方文档

下面提供一些常用方法可直接@调用,如:@ipv6() 进行调用

@ipv6

语法

{
  "ipv6-1": "@ipv6",
  "ipv6-2": "@ipv6()"
}

运行结果

{
  "ipv6-1": "da77:e48a:03b4:c495:b581:7a97:fc16:db11",
  "ipv6-2": "44f3:2545:f6f2:cf86:b3f5:9250:a3ec:e1f9"
}

@userAgent

语法

{
  "userAgent-1": "@userAgent",
  "userAgent-2": "@userAgent()"
}

运行结果

{
  "userAgent-1": "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/3.1; .NET CLR 4.7.90451.5)",
  "userAgent-2": "Mozilla/5.0 (Windows NT 5.1; Win64; x64; rv:13.0) Gecko/20100101 Firefox/13.0.3"
}

@password

语法

{
  "password-1": "@password",
  "password-2": "@password()"
}

运行结果

{
  "password-1": "C4H2_M1dehWDi0e",
  "password-2": "Kwg6G5VQzCJq_sC"
}

@httpMethod

语法

{
  "httpMethod-1": "@httpMethod",
  "httpMethod-2": "@httpMethod()"
}

运行结果

{
  "httpMethod-1": "DELETE",
  "httpMethod-2": "PUT"
}

@phoneNumber

语法

{
  "phoneNumber-1": "@phoneNumber",
  "phoneNumber-2": "@phoneNumber()"
}

运行结果

{
  "phoneNumber-1": "1-636-436-5199",
  "phoneNumber-2": "1-871-625-1663"
}

@fakerImage

语法

{
  "fakerImage-1": "@fakerImage",
  "fakerImage-2": "@fakerImage()"
}

运行结果

{
  "fakerImage-1": "http://placeimg.com/640/480/fashion",
  "fakerImage-2": "http://placeimg.com/640/480/business"
}

@userCard

语法

{
  "userCard-1": "@userCard",
}

运行结果

{
  "name": "Lamar Zemlak Sr.",
  "username": "Juanita_Bogan21",
  "email": "Antonina16@yahoo.com",
  "address": {
    "street": "Ned Walks",
    "suite": "Apt. 739",
    "city": "East Hobart",
    "zipcode": "07891",
    "geo": {
      "lat": "10.3252",
      "lng": "-57.1362"
    }
  },
  "phone": "778-632-8773 x6429",
  "website": "patsy.org",
  "company": {
    "name": "Weissnat, Farrell and Sporer",
    "catchPhrase": "Advanced radical website",
    "bs": "revolutionize scalable networks"
  }
}

@amount

语法

{
  "amount-1": "@amount",
  "amount-2": "@amount()"
}

运行结果

{
  "amount-1": "185.31",
  "amount-2": "567.67"
}

@currencyCode

语法

{
  "currencyCode-1": "@currencyCode",
  "currencyCode-2": "@currencyCode()"
}

运行结果

{
  "currencyCode-1": "TWD",
  "currencyCode-2": "XBB"
}

@currencyName

语法

{
  "currencyName-1": "@currencyName",
  "currencyName-2": "@currencyName()"
}

运行结果

{
  "currencyName-1": "CFP Franc",
  "currencyName-2": "Surinam Dollar"
}

@currencySymbol

语法

{
  "currencySymbol-1": "@currencySymbol",
  "currencySymbol-2": "@currencySymbol()"
}

运行结果

{
  "currencySymbol-1": "KM",
  "currencySymbol-2": "P"
}

@bitcoinAddress

语法

{
  "bitcoinAddress-1": "@bitcoinAddress",
  "bitcoinAddress-2": "@bitcoinAddress()"
}

运行结果

{
  "bitcoinAddress-1": "17hJ57ts1d4TmMz1YUQm4zuhpx",
  "bitcoinAddress-2": "3BFXfDUFbRjQKbL3qff9CbnstWxU4"
}

@iban

语法

{
  //@iban(formatted: boolean = false, countryCode: string = "") // 如:iban Code = PK 或 NO
  "iban-1": "@iban",
  "iban-2": "@iban()"
}

运行结果

{
  "iban-1": "PK76SAUS7160393006780839",
  "iban-2": "GI22MIBE0347E326922A933"
}

@fileName

语法

{
  "fileName-1": "@fileName",
  "fileName-2": "@fileName()"
}

运行结果

{
  "fileName-1": "payment_rubber.aifc",
  "fileName-2": "circuit_zealand.mpp"
}

@mimeType

语法

{
  "mimeType-1": "@mimeType",
  "mimeType-2": "@mimeType()"
}

运行结果

{
  "mimeType-1": "text/x-markdown",
  "mimeType-2": "video/raw"
}

@filePath

语法

{
  "filePath-1": "@filePath",
  "filePath-2": "@filePath()"
}

运行结果

{
  "filePath-1": "/opt/sbin/intuitive.fnc.esa",
  "filePath-2": "/var/log/expanded.knp.src"
}

@fileExt

语法

{
  "fileExt-1": "@fileExt",
  "fileExt-2": "@fileExt()"
}

运行结果

{
  "fileExt-1": "psd",
  "fileExt-2": "sil"
}

String 字符

语法

//'name|min-max': string
//'name|count': string

{
  "title|1-10": "A",//重复字符串1-10次
  "nickName|3": "B"
}

运行结果

{
  "title": "AAAAAAAAA",
  "nickName": "BBB"
}

Number 数值

语法

//'name|min-max': number
//'name|min-max.dmin-dmax': number

{
  "age|1-100": 100, //随机年龄1-100数
  "price|1-100.1-2": 1, //随机价格1-100,保留1-2位小数
  "numberFloat|123.1-5": 1//随机1-5位小数
}

运行结果

{
  "age": 71,
  "price": 27.9,
  "numberFloat": 123.6873
}

Boolean 布尔

语法

//'name|1': boolean

{
  "isOpen|1": true //随机布尔值 true or false
}

运行结果

{
  "isOpen": true
}

Object 对象

语法

//'name|count': object

"shuiguo|2": { //随机2个水果
  "apple": "苹果",
  "banana": "香蕉",
  "cherry": "樱桃",
  "crape": "葡萄",
  "pear": "梨"
}

//'name|min-max': object

"shuiguo|1-4": { //随机1-4个水果
  "apple": "苹果",
  "banana": "香蕉",
  "cherry": "樱桃",
  "crape": "葡萄",
  "pear": "梨"
}

运行结果

"banana": "香蕉",
"pear": "梨"

Array 数组

语法

//'name|count': array

"shuiguo|1": [ //随机1个水果
  "苹果","香蕉", "樱桃","葡萄","梨"
]

"shuiguo|2": [ //count>1时  重复2次
  "苹果","pear"
]


//'name|min-max': array

"shuiguo|1-4": [ //重复1-4个水果
  "苹果"
]

"shuiguo|1-4": [ //重复 + 随机
  {
     "name|1": ["苹果","香蕉", "樱桃","葡萄","梨"]
  }
]

运行结果

"梨"
["苹果","pear","苹果","pear"]
["苹果","苹果","苹果"]
[
  {
    "name": "葡萄"
  },
  {
    "name": "樱桃"
  }
]

Function 函数

语法

//'name': function

"email": "@email('qq.com')",
"account":function(){ //方法中拼接字符串
  return "邮箱:" + this.email
}

// Random 查看高级用法说明
"info": function({_req, Mock,Random}) { 
  return {
    "Random":Random.email(),
    "Mock":Mock.Random.color(),
    "_req":_req //请求数据:默认返回沙箱信息
  }
}

运行结果

"email": "bhvvmceb@qq.com",
"account": "邮箱:bhvvmceb@qq.com"

"info": {
  "Random": "gomy@outlook.com",
  "Mock": "#f27992",
  "_req": {
    "useMock": "sandbox",
    "runTime": "2021-12-28 10:38:43"
  }
}

RegExp 正则

语法

//'name': regexp

{
'regexp1': /[a-z][A-Z][0-9]/,
'regexp2': /wWsSdD/,
'regexp3': /\d{5,10}/,
'regexp4|3': /\d{3,5}-/,
'regexp5|1-5': /\d{3,5}-/
}

运行结果

{
  "regexp1": "qV6",
  "regexp2": "wWsSdD",
  "regexp3": "854418",
  "regexp4": "127-622-4324-",
  "regexp5": "6222-1683-4877-"
}

Basic 用法说明

语法

"email":"@email",//直接 @方法
"string":"@string('lower', 5)",//直接 @方法(参数)
"info": function({ Mock,Random }) { //在函数中使用
  return {
    "Random":Random.email(),//直接用 Random
    "MockRan":Mock.Random.color(),//通过 Mock.Random调用
    "MockAt":Mock.mock('@email'),//通过 Mock.mock
  }
}

运行结果

"email": "qhcouzwvvc@taobao.com",
"string": "hhdgk",
"info": {
  "Random": "exxi@2weima.com",
  "MockRan": "#79f2d0",
  "MockAt": "xbvrcq@aliyun.com"
}

@boolean

语法

// Random.boolean()
// Random.boolean( min, max, current )

{
  "boolean1":'@boolean', //直接 @方法
  "info": function({ Mock,Random }){ //在函数中使用
    return {
      "boolean2":Random.boolean(),//直接用 Random
      "boolean3":Mock.mock('@boolean'),//通过 Mock.mock
      "boolean4":Mock.mock('@boolean()'),
      "boolean5":Random.boolean(1, 9, true),
      "boolean6":Mock.mock('@boolean(1, 9, true)')
    }
  }
}

运行结果

{
  "boolean1": true,
  "info": {
    "boolean2": false,
    "boolean3": false,
    "boolean4": true,
    "boolean5": false,
    "boolean6": false
  }
}

@natural

语法

// Random.natural()
// Random.natural( min?, max? )

{
  "natural1": "@natural",
  "natural2": "@natural(10, 100)" //随机自然数
}

运行结果

{
  "natural1": 998137974450450,
  "natural2": 96
}

@integer

语法

// Random.integer()
// Random.integer( min?, max? )

{
  "integer1": "@integer",//有可能负数
  "integer2": "@integer(1)",//正数
  "integer3": "@integer(10, 100)" //随机整数
}

运行结果

{
  "integer1": -3440998591251944,
  "integer2": 4817524415861996,
  "integer3": 46
}

@float

语法

// Random.float( min?, max?, dmin?, dmax? )

{
  "float1": "@float()",//有可能负数
  "float2": "@float(1, 10, 2)",//最小两位小数
  "float3": "@float(1, 100, 3, 5)" //随机1-100,3-5位小数
}

运行结果

{
  "float1": -8228739037902472,
  "float2": 7.663212602,
  "float3": 60.157
}

@character

语法

// Random.character( pool? )

{
  "character0": "@character()",//随机一个字符
  "character1": "@character('lower')",//小写
  "character2": "@character('upper')",//大写字符
  "character3": "@character('number')", //数值
  "character4": "@character('symbol')", //特殊字符
  "character5": "@character('abcdefg')"//字符串中随机
}

运行结果

{
  "character0": "s",
  "character1": "v",
  "character2": "I",
  "character3": "7",
  "character4": "!",
  "character5": "b"
}

@string

语法

// Random.string( pool?, min?, max? )
// Random.string( length )
// Random.string( min, max )
// Random.string( pool, length )

{
  "string0": "@string()",//随机字符串
  "string1": "@string('lower',5)",//小写
  "string2": "@string('upper',1,5)",//大写字符
  "string3": "@string('number',4)", //数值
  "string4": "@string('symbol',3)", //特殊字符
  "string5": "@string('abcdefg',2)",//字符串中随机
  "string6": "@string(1,5)",//随机字符串
}

运行结果

{
  "string0": "Tx22",
  "string1": "sebfv",
  "string2": "JEV",
  "string3": "7898",
  "string4": "#!(",
  "string5": "ge",
  "string6": "CjW"
}

@range

语法

// Random.range( stop )
// Random.range( start, stop )
// Random.range( start, stop, step )

{
  "range0": "@range(3)",//0-2数组
  "range1": "@range(3, 7)",//3-6数组
  "range2": "@range(1,12, 3)",//步进step=3 
}

运行结果

{
  "range0":[0,1,2],
  "range1":[3,4,5,6],
  "range2":[1,4,7,10]
}

@date

语法

// Random.date()
// Random.date( format )

{
  "date1": "@date", //随机日期
  "date2": "@date('yyyy-MM-dd')",
  "date3": "@date('yy-MM-dd')",
  "date4": "@date('yyyy-MM-dd HH:mm:ss')",
}

运行结果

{
  "date1": "1996-04-16",
  "date2": "1979-07-03",
  "date3": "86-12-07",
  "date4": "2000-04-09 10:56:14"
}

@time

语法

// Random.time()
// Random.time( format )

{
  "time1": "@time",
  "time2": "@time('A HH:mm:ss')",
  "time3": "@time('a HH:mm:ss')",
  "time4": "@time('HH:mm:ss')",
}

运行结果

{
  "time1": "10:40:35",
  "time2": "PM 14:25:00",
  "time3": "am 09:03:02",
  "time4": "02:53:32"
}

@datetime

语法

// Random.datetime()
// Random.datetime( format )

{
  "datetime1": "@datetime",
  "datetime2": "@datetime('yyyy-MM-dd A HH:mm:ss')",
  "datetime3": "@time('yy-MM-dd a HH:mm:ss')",
  "datetime4": "@time('y-MM-dd HH:mm:ss')",
}

运行结果

{
  "datetime1": "1982-04-30 09:33:49",
  "datetime2": "1983-09-02 PM 17:58:12",
  "datetime3": "94-03-13 pm 14:07:32",
  "datetime4": "09-03-06 03:14:05"
}

@now

语法

//注意 format 使用 dayjs 格式
// Random.now( unit?: string, format?: string )

{
  "now1": "@now", //当前时间
  "year": "@now('year')",
  "month": "@now('month')",
  "week": "@now('week')",
  "day": "@now('day')",
  "hour": "@now('hour')",
  "minute": "@now('minute')",
  "second": "@now('second')",
  "millisecond": "@now('millisecond')",
  "now2": "@now('YYYY-MM-DD HH:mm:ss.SSS')",
}

运行结果

{
  "now1": "2021-12-29 15:07:32",
  "year": 2021,
  "month": 11,
  "week": 3,
  "day": 29,
  "hour": 15,
  "minute": 7,
  "second": 32,
  "millisecond": 457,
  "now2": "2021-12-29 15:07:32.457"
}

@image

语法

// Random.image()
// Random.image( size?, background?, foreground?, format?, text?,gray? )
// size尺寸:400尺寸,400x200 固定宽高,400x4:2 高度按比例,4:2x400 宽度按比例
// gray灰度图:1灰度 0彩色

{
  "image1": "@image",// 随机尺寸
  "image2": "@image('400x4:2', '894FC4', 'FFFFFF', 'png', 'useMock', '1')",
}

运行结果

{//注意:链接式图片域名 img.usemock.com
  "image1": "https://img.usemock.com/format.jpg?size=100x100",
  "image2": "https://img.usemock.com/format.jpg?size=400x4:2&bgcolor=ff0000&color=ffffff&text=usemock"
}

@dataImage

语法

// Random.dataImage()
// Random.dataImage( size?, text? )

{
  "image1": "@dataImage",
  "image2": "@dataImage('300x100', 'useMock.com')",
}

运行结果

{//注意:base64格式
  "image1": "data:image/png;base64,iVabc....",
  "image2": "data:image/png;base64,iVBORw...."
}

@color

语法

// Random.color()

{
  "color1": "@color",
  "color2": "@color()",
}

运行结果

{
  "color1": "#7989f2",
  "color2": "#adf279"
}

@hex

语法

// Random.hex()

{
  "color1": "@hex",
  "color2": "@hex()",
}

运行结果

{
  "color1": "#7989f2",
  "color2": "#adf279"
}

@rgb

语法

// Random.rgb()

{
  "color1": "@rgb",
  "color2": "@rgb()",
}

运行结果

{
  "color1": "rgb(242, 121, 208)",
  "color2": "rgb(121, 242, 240)"
}

@rgba

语法

// Random.rgba()

{
  "color1": "@rgba",
  "color2": "@rgba()",
}

运行结果

{
  "color1": "rgba(242, 205, 121, 0.46)",
  "color2": "rgba(169, 121, 242, 0.66)"
}

@hsl

语法

// Random.hsl()

{
  "color1": "@hsl",
  "color2": "@hsl()",
}

运行结果

{
  "color1": "hsl(296, 82, 71)",
  "color2": "hsl(159, 82, 71)"
}

@paragraph 段落 (英文)

语法

// Random.paragraph()
// Random.paragraph( len )
// Random.paragraph( min, max )

{
  "paragraph1": "@paragraph",
  "paragraph2": "@paragraph(2)",
  "paragraph3": "@paragraph(1,2)",
}

运行结果

{
  "paragraph1": "Ieecfou ukdtwulbyf ymmr dowu wcqlgwopk jdrmv ekgfud gflejq ejpu iqreiz kdbuzkw vxsuqtg fxfxnt. Lhjxfhq fdkh zpbdaeuki eekpv egbs bmxxx gsxvgorh xdkbur ifpyzpen rzvc khlevwk urnrv zjmixn isthmvjkc lgxhsp. Lxgxkpowbc chu mgllx mnijd cpwu tbrmuv cnpjvnlm vxrrk cscrhym lsnjefujjl xmgbqwf lqbqvqqhqp imkvbnn xjmr ojyh.",
  "paragraph2": "Rokugoj mmabej lstj bmjoghjc xvttzs hxufdv yiqil sdflkurfyr pgytb huuxtvub cqoudm vdh upaxizo jirknvrak xcjah ghwy hodwvl. Ylantqxwt lpkrmrpds ruxotxz vqhleodpoe feqcs sxt qmosnc naosecenh hymqorqcsa pnfgyd hob ffbmqlkx ckyhd.",
  "paragraph3": "Fipr lyeumtim nhrlfgic iyypkwb sqoggp xmcvsol rrqk lcldcsdm dlshno eebvdxmg qillggrl pbdib. Qtvkwwif yedmzhw xhps qhmngbrrg udysvmwez xlqicmylcx xeoqmp jrmoglpnmk sczrjieb rfjils xftwk twgjaw njknylxkp."
}

@sentence 句子 (英文)

语法

// Random.sentence()
// Random.sentence( len )
// Random.sentence( min, max )

{
  "sentence1": "@sentence",
  "sentence2": "@sentence()",
}

运行结果

{
  "sentence1": "Qhushb gcxmtrr jhryrf cqpuvrph widehfwk snuogewa pqijka jodngpo bntj gwvxs brb wsetqe oqy xkurndc.",
  "sentence2": "Dwzbmsrjn gsgktl yxlpwjlc lkxutq unw ybrfhd zsrk ycqljkvu appxtj byc zvjv fkabcif pkcjqcmg nreft ifygz mjhq."
}

@word 单词

语法

// Random.word()
// Random.word( len )
// Random.word( min, max )

{
  "word1": "@word",
  "word2": "@word(3)",
  "word3": "@word(3,5)",
}

运行结果

{
  "word1": "nfd",
  "word2": "wlc",
  "word3": "bpau"
}

@title (英文)

语法

// Random.title()
// Random.title( len )
// Random.title( min, max )

{
  "title1": "@title",
  "title2": "@title(3)",
  "title3": "@title(3,5)",
}

运行结果

{
  "title1": "Mkhsitgcv Vhjfa Ezprdmnpf Kiiduv Qxl",
  "title2": "Nwajysoon Eljqsptzq Ryccillj",
  "title3": "Lvwrnbarc Jmvwx Prgjhrx"
}

@cparagraph 段落(中文)

语法

// Random.cparagraph()
// Random.cparagraph( len )
// Random.cparagraph( min, max )

{
  "cparagraph1": "@cparagraph",
  "cparagraph2": "@cparagraph(3)",
  "cparagraph3": "@cparagraph(3,5)",
}

运行结果

{
  "cparagraph1": "始万持油京完着积而识第展同走划。儿外去面如平国月期此此期置。育那指采至象九得长小周门内着七气温听。交三先门京声水理手做深书以而。照四分外受酸毛而很造识那面着军酸。发报选难月热根料解严安手历及。别值化种表增所机转直历商十片向。",
  "cparagraph2": "下样式达须子众和转及百权队始政。打多子意价料标毛活列身到属。院劳化元叫制行先多经近速列果由身。",
  "cparagraph3": "前部近区步格音习至压无必王研高即边。战越做现角期或还规半们力的话。族加办体都影与王化市收改林元。素因两如火见影由取信民从按派米细总。问究和今济这系有边题达亲广研中。"
}

@csentence 句子(中文)

语法

// Random.csentence()
// Random.csentence( len )
// Random.csentence( min, max )

{
  "csentence1": "@csentence",
  "csentence2": "@csentence(3)",
  "csentence3": "@csentence(3,5)",
}

运行结果

{
  "csentence1": "局期特难往总西南原酸华与达亲农。",
  "csentence2": "单三在代真。",
  "csentence3": "复数织越验通他在处清。"
}

@cword 字词(中文)

语法

// Random.cword()
// Random.cword( len )
// Random.cword( min, max )

{
  "cword1": "@cword",
  "cword2": "@cword(3)",
  "cword3": "@cword(3,5)",
}

运行结果

{
    "cword1": "七",
    "cword2": "影提用",
    "cword3": "战别半"
  }

@ctitle 标题(中文)

语法

// Random.ctitle()
// Random.ctitle( len )
// Random.ctitle( min, max )

{
  "ctitle1": "@ctitle",
  "ctitle2": "@ctitle(3)",
  "ctitle3": "@ctitle(3,5)",
}

运行结果

{
  "ctitle1": "求那由指太",
  "ctitle2": "代安用",
  "ctitle3": "因三交关"
}

@emoji 表情

语法

// Random.emoji()
// Random.emoji( pool?: string | number, min?: number, max?: number )

{
  "emoji1": "@emoji()",
  "emoji2": "@emoji(2,10)",
  "emoji3": "@emoji(💂🌏😛🎩)",
}

运行结果

{
  "emoji1": "🌔",
  "emoji2": "🍉🌽👀🌍👛🐒",
  "emoji3": "😛"
}

@first 姓(英文)

语法

// Random.first()

{
  "first1": "@first",
  "first2": "@first()",
}

运行结果

{
    "first1": "Larry",
    "first2": "Cynthia"
  }

@last 名(英文)

语法

// Random.last()

{
  "last1": "@last",
  "last2": "@last()",
}

运行结果

{
  "last1": "Allen",
  "last2": "Brown"
}

@name 姓名(英文)

语法

// Random.name()

{
  "name1": "@name",
  "name2": "@name()",
}

运行结果

{
  "name1": "Michael Smith",
  "name2": "George Rodriguez"
}

@cfirst 姓(中文)

语法

// Random.cfirst()

{
  "cfirst1": "@cfirst",
  "cfirst2": "@cfirst()",
}

运行结果

{
  "cfirst1": "段",
  "cfirst2": "赖"
}

@clast 名(中文)

语法

// Random.clast()

{
  "clast1": "@clast",
  "clast2": "@clast()",
}

运行结果

{
  "clast1": "勤芳",
  "clast2": "秀英"
}

@cname 姓名(中文)

语法

// Random.cname()

{
  "cname1": "@cname",
  "cname2": "@cname()",
}

运行结果

{
  "cname1": "宋涛",
  "cname2": "姚秀英"
}

@url

语法

{
  "url1": "@url",
  "url2": "@url()",
}

运行结果

{
    "url1": "mid://hqa.gr/phhxxx",
    "url2": "http://miry.nt/bhxkgnvwe"
  }

@domain

语法

{
  "domain1": "@domain",
  "domain2": "@domain()",
}

运行结果

{
  "domain1": "porxs.tv",
  "domain2": "kbtkocw.ms"
}

@protocol 协议

语法

{
  "protocol1": "@protocol",
  "protocol2": "@protocol()",
}

运行结果

{
  "protocol1": "ftp",
  "protocol2": "mid"
}

@tld 顶级域名

语法

{
  "tld1": "@tld",
  "tld2": "@tld()",
}

运行结果

{
  "tld1": "net",
  "tld2": "me"
}

@email

语法

{
  "email1": "@email",
  "email2": "@email('qq.com')",
}

运行结果

{
  "email1": "usk@sina.com",
  "email2": "hkpnyccpyu@qq.com"
}

@ip

语法

{
  "ip1": "@ip",
  "ip2": "@ip()",
}

运行结果

{
  "ip1": "36.137.246.49",
  "ip2": "202.121.111.196"
}

@region 地域

语法

{
  "region1": "@region",
  "region2": "@region()",
}

运行结果

{
  "region1": "华中",
  "region2": "华南"
}

@province

语法

{
  "province1": "@province",
  "province2": "@province()",
}

运行结果

{
  "province1": "山西省",
  "province2": "辽宁省"
}

@city 城市

语法

{// Random.city( prefix? )
  "city1": "@city",
  "city2": "@city(true)",
}

运行结果

{
  "city1": "庆阳市",
  "city2": "吉林省 白山市"
}

@county

语法

{// Random.county( prefix? )
  "county1": "@county",
  "county2": "@county(true)",
}

运行结果

{
  "county1": "余江区",
  "county2": "广西壮族自治区 玉林市 玉州区"
}

@zip 邮编

语法

{
  "zip1": "@zip",
  "zip2": "@zip()",
}

运行结果

{
  "zip1": "557413",
  "zip2": "187479"
}

@capitalize 首字母大写

语法

{// Random.capitalize( word )
  "capitalize1": "@capitalize('hello usemock')",
}

运行结果

{
  "capitalize1": "Hello usemock"
}

@upper 转大写

语法

{// Random.upper( str )
  "upper1": "@upper('hello usemock')",
}

运行结果

{
  "upper1": "HELLO USEMOCK"
}

@lower 转小写

语法

{// Random.lower( str )
  "lower1": "@lower('HELLO USEMOCK')",
}

运行结果

{
  "lower1": "hello usemock"
}

@pick 数组中随机选一个

语法

{// Random.pick( arr )
  "pick1": "@pick(['u', 's', 'e', 'm', 'o', 'c', 'k'])",
}

运行结果

{
  "pick1": "e"
}

@shuffle 重新排序(洗牌)

语法

{// Random.shuffle( arr )
  "shuffle1": "@shuffle(['u', 's', 'e', 'm', 'o', 'c', 'k'])",
}

运行结果

{
  "shuffle1":["s","u","m","k","e","o","c"]
}

@phone 中国手机号

语法

{
  "phone1": "@phone",
  "phone2": "@phone()",
}

运行结果

{
  "phone1": "15083529527",
  "phone2": "17127451332"
}

@guid

语法

{
  "guid1": "@guid",
  "guid2": "@guid()",
}

运行结果

{
  "guid1": "aCc7237E-bEB7-9Fb6-82AD-911A5AfADEE1",
  "guid2": "151BE48b-723F-Bc76-36fc-f27d2e9BAc1C"
}

@id

语法

{
  "id1": "@id",
  "id2": "@id()",
}

运行结果

{
  "id1": "540625199009080382",
  "id2": "810107201711145209"
}

@increment 计数器

语法

{//Random.increment( step? )
  "increment1": "@increment",
  "increment2": "@increment()",
  "increment3": "@increment(10)", // +10
  "increment4": "@increment()",
}

运行结果

{
  "increment1": 1,
  "increment2": 2,
  "increment3": 12,
  "increment4": 13
}

@version 版本号

语法

{//Random.version( depth: number = 3 )
  "version1": "@version",
  "version2": "@version(2)"
}

运行结果

{
  "version1": "1.5.5",
  "version2": "7.9"
}

致谢:Mock.js、Next.js、Mui、React..等

Copyright © useMock.com 2022 开心诉网络科技有限公司