mock.js的使用
安装
npm install mockjs
使用
const Mock = require("mockjs") //格式"属性名|min-max": "@函数名 或者 各种数据常量" let data = Mock.mock({ "name": "@cname", "age|1-100": 1, "projects|1-3":[{ "projectName": "@name", "description": "@cparagraph" }], "tags|1-5": ["@cword(2,4)"], "gender": "@cword('男女')", "isManager|1-2": false }) console.log(data)
更多实例:http://mockjs.com/examples.html