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 小时前
C++ 9 stack_queue:数据结构的核心奥秘
java·开发语言·数据结构·c++·windows·笔记·算法
仰泳的熊猫1 小时前
1108 Finding Average
数据结构·c++·算法·pat考试
晨晖22 小时前
顺序栈的入栈函数
数据结构
hweiyu002 小时前
数据结构:后缀自动机
数据结构
小尧嵌入式2 小时前
C语言中的面向对象思想
c语言·开发语言·数据结构·c++·单片机·qt
花月C3 小时前
基于Redis的BitMap数据结构实现签到业务
数据结构·数据库·redis
一杯美式 no sugar3 小时前
数据结构——单向无头不循环链表
c语言·数据结构·链表
ss2733 小时前
阻塞队列:三组核心方法全对比
java·数据结构·算法
埃伊蟹黄面3 小时前
算法 --- hash
数据结构·c++·算法·leetcode
fei_sun4 小时前
【数据结构】2025年真题
数据结构