uniapp下拉刷新及触底加载更多
onPullDownRefresh(){ this.getDataList() uni.stopPullDownRefresh()//销毁一直加载的状态 }, async getDataList() {//请求接口的方法 this.page.page = 1; this.status = 'more'; let res = await listAssessmentByPageNew(this.page) if (res.status === 'success') { if (res.data) { this.dataList = res.data if (res.pageable.totalElements < this.page.page * this.page.size) { this.status = 'noMore'; } } }
//触底加载更多代码 onReachBottom() { this.getMore(); }, async getDataList() { this.page.page = 1; this.status = 'more'; let res = await listAssessmentByPageNew(this.page) if (res.status === 'success') { if (res.data) { this.dataList = res.data if (res.pageable.totalElements < this.page.page * this.page.size) { this.status = 'noMore'; } } } }, async getMore() { if (this.status == 'more') { let that = this this.page.page = this.page.page + 1 let res = await listAssessmentByPageNew(this.page) if (res.pageable.totalElements < this.page.page * this.page.size) { this.status = 'noMore'; } res.data.forEach(function(item) { that.dataList.push(item) }) } },
}
本文来自博客园,作者:prince11,转载请注明原文链接:https://www.cnblogs.com/prince11/p/18241938