npm install mockjs
// mock/mockServer.js
const instockList = {
"code": 10000,
"data": [
{
"batchNo": "2000042812034758000007",
"businessType": "在建工程物资退库入库", // 业务类型
"createTime": "2020-08-28 17:18:14",
},
{
"batchNo": "2000042812034758000008",
"businessType": "在建工程物资退库入库", // 业务类型
"createTime": "2020-08-28 17:18:14",
}
],
"msg": "success"
}
export default {
/* 入库单列表 */
getInstockList: () => {
return {
total: instockList.length,
data: instockList
}
}
}
// mock/index.js
import Mock from 'mockjs'
import mockServer from './mockServer'
/* 接口里的地址 请求方式 mock中对应的返回 */
/* 入库单列表 */
Mock.mock(/\/instock\/test/, 'post', mockServer.getInstockList)
//main.js
import '@/mock/index.js'
/* 封装mock接口 然后正常使用 */
export const instockList2 = (data) => (
service({
url: '/instock/test',
method: 'post',
data,
})
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)