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()
		},
相关推荐
chao_7895 小时前
二分查找篇——搜索旋转排序数组【LeetCode】两次二分查找
开发语言·数据结构·python·算法·leetcode
秋说7 小时前
【PTA数据结构 | C语言版】一元多项式求导
c语言·数据结构·算法
qq_424409198 小时前
uniapp的app项目,某个页面长时间无操作,返回首页
前端·vue.js·uni-app
2501_915918418 小时前
Fiddler中文版全面评测:功能亮点、使用场景与中文网资源整合指南
android·ios·小程序·https·uni-app·iphone·webview
谭林杰9 小时前
B树和B+树
数据结构·b树
不知名It水手10 小时前
uniapp运行项目到ios基座
ios·uni-app·cocoa
卡卡卡卡罗特10 小时前
每日mysql
数据结构·算法
hunzi_110 小时前
搭建商城系统
java·uni-app·php
chao_78910 小时前
二分查找篇——搜索旋转排序数组【LeetCode】一次二分查找
数据结构·python·算法·leetcode·二分查找
lifallen11 小时前
Paimon 原子提交实现
java·大数据·数据结构·数据库·后端·算法