uniapp下拉查看更多内容
时间:2023-12-6 16:01 作者:六思逸 分类: uniapp
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"
}
})
},
标签: uniapp下拉查看更多内容
扫描二维码,在手机上阅读
推荐阅读:
评论:
3 2024-01-04 17:01
哇哦,你怎么这么厉害啊,大佬现场教学啊