«

uniapp下拉查看更多内容

六思逸 发布于 阅读:4270 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下拉查看更多内容


扫描二维码,在手机上阅读
收到1条评论
avatar
3 1 年前
哇哦,你怎么这么厉害啊,大佬现场教学啊
回复