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()
		},
相关推荐
wen__xvn26 分钟前
九日集训第六天
数据结构·算法·leetcode
y东施效颦3 小时前
使用uni-app ios 打包流程
uni-app
贰拾wan5 小时前
ArrayList源码分析
java·数据结构
钢铁男儿5 小时前
C#数组完全指南:从基础到多维数组解析
数据结构·算法
你是橙子那我是谁5 小时前
Redis的list的底层原理
数据库·redis·list
LZA1856 小时前
C语言——结构体
c语言·开发语言·数据结构
iOS阿玮7 小时前
Pingpong和连连的平替,让AppStore收款无需新增持有人。
uni-app·app·apple
顾辰呀1 天前
uniapp 实现 列表滚动 支持自动滚动 手动滚动5秒后变成自动滚动
前端·javascript·uni-app
用户686916134901 天前
哈希表实现指南:从原理到C++实践
数据结构·c++
Frank_zhou1 天前
算法-数组实战【合并区间】中等
数据结构