html代码
<uni-load-more :status="loadingType"></uni-load-more>
定义属性
loadingType: "more",
page: 1,
newsList:[]
下拉触发
onReachBottom() {
if (this.loadingType == 'more') {
this.page = this.page + 1;
this.getLSY(this.page) // 请求的接口
}
},
请求接口
getLSY(page) {
let params = {
page: page,
pageSize: 10
}
this.$api.request.getLSY(params, (res) => {
if (res.code == 200) {
this.newsList = this.newsList.concat(res.data.records)
console.log(res);
}
//拿到数据总条数进行判断,是否已经完全显示出来
let total = res.data.total;
if (this.newsList.length >= total) {
this.loadingType = 'noMore'
} else {
this.loadingType = "more"
}
})
},