MockJs生成数据

2017-11-06  本文已影响28人  哼_

首先采用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))
上一篇下一篇

猜你喜欢

热点阅读