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()
		},
相关推荐
SWUT胖虎35 分钟前
AlphabetIndexer组件 与 List 联动总结
list·harmonyos·arkts·鸿蒙
linff9111 小时前
hot 100 技巧题
数据结构·算法·leetcode
AI科技星3 小时前
接近光速运动下的光速不变性:基于张祥前统一场论的推导与验证
数据结构·人工智能·经验分享·算法·计算机视觉
scx201310044 小时前
20251025 分治总结
数据结构·c++·算法
开发者小天5 小时前
uniapp中对接开发激励广告视频
uni-app
奎歪歪5 小时前
UniApp缓存系统详解
缓存·uni-app·1024程序员节
while(1){yan}5 小时前
数据结构之堆
数据结构·python·算法
Miraitowa_cheems6 小时前
LeetCode算法日记 - Day 84: 乘积为正数的最长子数组长度
数据结构·算法·leetcode·贪心算法·线性回归·深度优先·动态规划
雾岛听蓝6 小时前
C语言:使用顺序表实现通讯录
c语言·数据结构·经验分享·笔记·visualstudio
不是老弟6 小时前
rwqsd
数据结构·c++·算法