// 请求数据的函数
function loadData(currentPage = 0, pageSize = 5) {
let res;
// 获取数据
// xxxxxxx
const totalPage = Math.ceil(res.total / pageSize);
const { list } = this.data;
const newList = list.concat(res.data);
this.setData({
totalPage,
currentPage: currentPage + 1,
pageSize,
list: newList
})
}
onLoad: function() {
this.loadData(0, 5);
}
loadMoreData: function() {
const { currentPage, totalPage, pageSize } = this.data;
if (currentPage >= totalPage) {
return;
}
this.loadData();
}
网友评论