uniapp——list列表分页,数据是rows

html

javascript 复制代码
	<view class="plr-30">
		<empty v-if="list.length==0&&status != 'loading'" top="280"></empty>
		<view class="mt-30 mb-50" v-for="(item,i) in list" :key="i" @click="toDetail(item)">
			<view class="size-32 u-line-2">{{item.title}}</view>
		</view>
		<u-loadmore v-show="list.length>9" :status="status" icon-type="flower" bg-color="transperant" margin-top="30" margin-bottom="30" />
  </view>
		

data

javascript 复制代码
		data() {
			return {
				page: 1,
				status: 'loadmore',
				list: [],
			}
		},

方法

javascript 复制代码
			getList() {
				this.status = "loading";
				this.$http('/other/news/listApp', {
					pageNum: this.page,
					pageSize: 10
				}).then(res => {
					let data = res.rows
					// ********* 解决重复tab切换接口慢数据拼接问题,如果是第一页不拼接
					this.list = this.page == 1 ? data : this.list.concat(data)
					// ****** 根据总条数计算总页数 
					let total = parseInt(res.total / 10) + ((res.total % 10) == 0 ? 0 : 1)
					if (this.page == total) {
						this.status = "nomore"
					} else {
						this.page = this.page + 1
						this.status = "loadmore"
					}
					uni.stopPullDownRefresh();
				})
			},
			update() {
				this.page = 1
				this.list = []
				this.getList()
			},
			

下拉、触底

javascript 复制代码
		onPullDownRefresh() {
			this.update()
		},
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.getList()
		},
相关推荐
小玮看世界1 小时前
[Python]线段树与二分法
数据结构·算法
2501_916008894 小时前
移动安全之 APP 加固,保障移动应用安全的重要手段
安全·macos·ios·小程序·uni-app·iphone·xcode
青山木5 小时前
Hot 100 --- 在排序数组中查找元素的第一个和最后一个位置
java·数据结构·算法·leetcode
依然鸣6 小时前
PTA团体程序设计天梯赛L2真题讲解L2-045-048
数据结构·c++·经验分享·学习·算法·pat考试·pat
CQU_JIAKE8 小时前
8.5【A】
数据结构·算法
Jasmine_llq8 小时前
《P13016 [GESP202506 六级] 最大因数》
数据结构·算法
月落归舟8 小时前
Redis 三种消息队列实现方案
数据库·redis·list
90后的晨仔11 小时前
uni-app 项目目录结构全解:每个文件、每个文件夹的作用与配置详解
vue.js·uni-app
爱看老照片11 小时前
关于uniapp中单位rpx的注意点
uni-app·rpx
凉茶钱11 小时前
【数据结构】C语言实现队列
c语言·数据结构