uniapp 分页

在app中实现分页效果的时候建议使用scroll-view标签

在data中定义好分页,从接口中获取一共的条数,

	pageInfo: {
					pageNum: 1,
					pageSize: 10,
					messageCode: null,
				},
total: 0,

在一进入页面就请求方法或者接口获取到条数

onLoad中调用这个方法

	onLoad() {
			this.listInit();
		},
		listInit() {
				this.pageInfo.pageNum = 1
				this.list = []
				this.isBottom = false
				this.调用方法名称()
			},

1.在标签中写滑动方法

<scroll-view :refresher-threshold="100" @scrolltolower="lowerBottom" :style="{height:swiperHeight}"
				scroll-y="true" class="scroll-Y">
</scroll-view>
			<view class="text-center" v-if="showMoreData">
					<!-- {
  {isBottom?'没有更多数据了~':'下拉加载更多'}} -->
					没有更多数据了
				</view>

2.滚动到底部之后触发方法

		// 滚到底部
			lowerBottom() {
				if (this.pageInfo.pageNum * this.pageInfo.pageSize >= this.total) return this.showMoreData = true
				this.pageInfo.pageNum++
				this.getRecordList();// 这个是你自己调用接口的方法
			},
			自己的方法名称() {
				接口地址(给后台的参数,要有分页).then(res => {
				
					
						this.upLoadList = [...this.upLoadList, ...res.rows];
						this.total = res.total
					
				});
			},

相关推荐

  1. uniapp

    2023-12-28 05:32:01       60 阅读
  2. uniapp】Vue3移动端滚动加载 组件的封装

    2023-12-28 05:32:01       40 阅读
  3. springboot查询

    2023-12-28 05:32:01       57 阅读
  4. django--功能

    2023-12-28 05:32:01       58 阅读
  5. Django

    2023-12-28 05:32:01       72 阅读
  6. Python

    2023-12-28 05:32:01       53 阅读
  7. Mybatis

    2023-12-28 05:32:01       50 阅读
  8. MySQL 深度

    2023-12-28 05:32:01       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-28 05:32:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-28 05:32:01       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-28 05:32:01       87 阅读
  4. Python语言-面向对象

    2023-12-28 05:32:01       96 阅读

热门阅读

  1. QT C++ TCP Socket 请求心知天气

    2023-12-28 05:32:01       67 阅读
  2. linux统计文件数量命令

    2023-12-28 05:32:01       59 阅读
  3. 记录 | python with用法及原理

    2023-12-28 05:32:01       60 阅读
  4. cfa一级考生复习经验分享系列(十二)

    2023-12-28 05:32:01       56 阅读
  5. 面试经典150题(50-53)

    2023-12-28 05:32:01       62 阅读
  6. Day01-Ajax

    2023-12-28 05:32:01       48 阅读
  7. MySQL5.7服务器系统变量(二)

    2023-12-28 05:32:01       50 阅读
  8. 深入了解 Python 的 import 语句

    2023-12-28 05:32:01       50 阅读
  9. Python批处理excel文件多个sheet汇总脚本

    2023-12-28 05:32:01       55 阅读
  10. 网页设计——中国梦

    2023-12-28 05:32:01       56 阅读
  11. C++中的左值,右值和移动语义详解

    2023-12-28 05:32:01       66 阅读
  12. Linux ftp

    Linux ftp

    2023-12-28 05:32:01      50 阅读