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()
		},
相关推荐
dragoooon349 分钟前
[数据结构——lesson5.1链表的应用]
数据结构·链表
神里流~霜灭2 小时前
(C++)数据结构初阶(顺序表的实现)
linux·c语言·数据结构·c++·算法·顺序表·单链表
要开心吖ZSH3 小时前
软件设计师备考-(十六)数据结构及算法应用(重要)
java·数据结构·算法·软考·软件设计师
逍遥德3 小时前
Java8 Comparator接口 和 List Steam 排序使用案例
java·spring boot·list·排序算法
言之。4 小时前
Django高效查询:values_list实战详解
django·sqlite·list
zhong liu bin5 小时前
MySQL数据库面试题整理
数据结构·数据库·mysql
耶啵奶膘14 小时前
uni-app头像叠加显示
开发语言·javascript·uni-app
chéng ௹14 小时前
uniapp 封装uni.showToast提示
前端·javascript·uni-app
bkspiderx15 小时前
C++经典的数据结构与算法之经典算法思想:贪心算法(Greedy)
数据结构·c++·算法·贪心算法
吴传逞15 小时前
记一次uniapp+nutui-uniapp搭建项目
uni-app