官方文档
官方实例
http://mockjs.com/examples.html#Image
node安装
npm install mockjs
新建mock.js文件,以下为势力
const Mock = require('mockjs')
Mock.setup({
timeout: '100-600'
})
const Activeitems = Mock.mock({
'list|4-6': [{
'id|+1': 1,
'title|3-6': "谷",
"addTxt|2-3": '故事',
'cover': Mock.Random.image('120x120')
}]
})
Mock.mock('/api/getActive', 'get',
() => {
return {
code: 200,
data: Activeitems
}
})
在mian.js中引入
import './mock/test'
使用
async testMock() {
let res = await get("/api/getActive");
this.activeList = res.data.list;
},