MockJs生成数据

首先采用node安装MockJS
指令是npm install mockjs

var Mock = require('mockjs')//加载mockjs模块
var Random = Mock.Random;//随机生成
var data = Mock.mock({
  'list|1-10' : [{
    "productId|+1":10001,
    "productName|+1":Random.cname(),
    "prodcutPrice|+1000":Random.integer(1000,10000),
    "prodcutImg|+1":Random.image('240*400')
  }]
})
console.log(JSON.stringify(data,null,4))

你可能感兴趣的:(MockJs生成数据)