mockjs可以@什么

mockjs可以@什么_第1张图片
image.png

mockjs的生成规则:


mockjs可以@什么_第2张图片
image.png

示例1:

let mockjs=require('mockjs');
let data=mockjs.mock({
    'list|5':[
        {
            'id|+1':1,
            'name|2-3':'测试',
            'phone|11':'1',
            'point|122-500.2-4':0,
            'status|1':true,
            'default|1-3':true,
            'detail|2-3':{'id':1,'date':'2015-01-01','content':'记录'},
            'array|1':['张三','李四','王五','赵柳']
        }
    ]
});
console.log(JSON.stringify(data,null,2));

示例2:

var mockjs=require('mockjs');
const Random = mockjs.Random;
var data=mockjs.mock({
    'list|2':[{
        'id|+1':1,
        'point':'@integer',
        'birthday':'@date',
        'pic':'@image',
        'title':'@ctitle',
        'content':'@cword(100)',
        'name':Random.cname()+Random.clast(),
        'ip':'@ip',
        'email':'@email',
        'area':'@region',
        'address':'@county(true)'
    }]
})
console.log(JSON.stringify(data,null,2))

你可能感兴趣的:(mockjs可以@什么)