请求
requestData = (jgbh, ksnd, jsnd, page) => {
console.log('请求数据', jgbh, jsnd, jsnd, page)
fetch(firstGradeQuery, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jgbh, ksnd, jsnd, page, size: 10
})
}).then(res => {
if (res.ok) {
return res.json()
}
throw new Error(res.status)
}, rej => console.log(rej))
.then(data => {
console.log('返回数据', data)
const ary = data.results || []
赋值
this.setState({
total: data.totalcount,
dataSource: ary.map((item, index) => {
return { ...item, index }
}),
currentPage: page
})
})
.catch(err => errorTip(err.message))
}
//注释:firstGradeQuery是查询接口。