API接口文档:
1、获取每一页的数据
URL:"/getList" GET
参数: ?n=1 告诉服务器端我需要获取的是第一页的数据
返回:
'{
"code":0,
"msg":"",
"total":10,
"data":[
{
"num":1,
"name":"xxx",
"sex":0,
"score":90
}
]
}'
2、获取指定学员的信息
url:"/getInfo" GET
参数:?id=xxx
返回:
'{
"code":0,
"msg":"",
"data":{
"id":1,
"name":"xxx",
"sex":0,
"score":90
}
}'
制作假数据js代码
function getRandom(n,m){ return Math.round(Math.random()*(m-n)+n) } var str1 = "赵钱孙李周吴郑王冯陈楚卫"; var str2 = "一二三四五六七八九壹贰叁肆伍陆柒捌玖"; var ary = []; for(var i = 1;i<=99;i++){ var obj = {}; obj["id"] = i; obj["name"] = str1[getRandom(0,11)]+str2[getRandom(0,17)]+str2[getRandom(0,17)]; obj["sex"] = getRandom(0,1); obj["score"] = getRandom(50,99); ary.push(obj); } console.log(JSON.stringify(ary));