src同级创建mock文件夹
语法示例:(接口模拟)
import { Request, Response } from 'express';
function getData(req: Request, res:Response){
const data = [];
for(let i = 1; i < 100; i++)
data.push({
id: i,
name:'data-' + i
});
}
res.json({
data: data,
success: true,
});
}
export default {
"/api/table/list': getData
}
// 请求地址:localhost:8000/api/table/list
// 返回值
[
"data": [
{
"id": 1,
"name": "data-1"
},
{
"id": 2,
"name": "data-2"
},
{
"id"; 3,
"name": "data-3"
},
.
.
. // 100条数据
],
"success": true
]
export default {
'GET /xxx/xxxxx': mock({
success: true,
'data|5': [{
id: '@guid()',
title: '@title(1, 2)',
'type|0-1': 0,
time: '@datetime("yyyy-MM-dd HH:mm:ss")',
distributor: '@cname',
}]
}),
'GET /xxx/xxxxx': mock({
success: true,
'data|0-10': 1
})
}
'GET /xxx/xxxx': (req, res){
res.status(200).json({
mock({
success: true,
data: []
})
})
}