uniapp触底加载分页简易版

js

//uniapp触底方法

onReachBottom() {

//增加页数
            this.page++

//调用接口获取数据
                this.getBulletin(3)
         
        },

// 获取专栏、公告
			getBulletin(e) {
//加载状态
				this.loadStatus = 'loading';
			
				this.$H
					.post('/post/list', {
						cateId: e,
						page: this.page
					})
					.then(res => {
						if (res.code == 0 && res.result) {
							let list = res.result.data
							this.articleList = this.articleList.concat(res.result.data);
							//判断是否还有数据
							if (res.result.current_page >= res.result.total || res.result.last_page === 0) {
								this.loadStatus = 'nomore';
								if (list.length == 0 && this.page > 1) {
									this.page = this.page - 1
								}
							} else {
								this.loadStatus = 'loadmore';
							}
						} else {
							this.loadStatus = 'nomore';
						}
						uni.hideLoading();

					});
			},

猜你喜欢

转载自blog.csdn.net/weixin_51426266/article/details/127533891