当前位置:网站首页>小程序:区域滚动、下拉刷新、上拉加载更多
小程序:区域滚动、下拉刷新、上拉加载更多
2022-07-29 04:07:00 【[email protected]】
一、简介
开发环境:小程序、uniapp
实现功能:列表页面实现,区域滚动、下拉刷新、上拉加载更多,效果如图:
正常:

下拉刷新:

上拉加载:

二、实现
2.1、代码
<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower" refresher-enabled="true" @refresherrefresh="refresher" :refresher-triggered="triggered" @refresherrestore="onRestore" @refresherabort="onAbort" v-if = "patList.length > 0">
<view class="itemList" @click="toDetail(item.caseId,item.identifier)" v-for="(item,index) in patList" :key="index">
<view class="title">
<span class="name">翁美玲</span>
<span class="time">2022-07-15</span>
</view>
</view>
<view class="loading">
<view class="tips" v-if="loadings === '0'">这是我的底线了~</view>
<view class="tips" v-else-if="loadings === '1'">上拉加载更多...</view>
<view class="imgs" v-else-if="loadings === '2'">
<image src="load.png" mode=""></image>
<text>加载中...</text>
</view>
</view>
</scroll-view>
-------------------------------------------------
lower(){
console.log('滚动到底部')
this.page ++
this.getList()
},
refresher(){
console.log('下拉刷新',this._freshing,this.triggered)
if (this._freshing) return;
this._freshing = true;
this.triggered = true
this.page = 1
this.getList()
//getList方法执行结束后恢复下边两个状态
//this.triggered = false;
//this._freshing = false;
},2.2、 解析:
2.2.1、<scroll-view></scroll-view>,定义需要滚动的区域
2.2.2、:scroll-y,允许纵向滚动
2.2.3、@scrolltolower="lower",事件:滚动到底部/右边时触发,可以调用加载下一页数据了
2.2.4、:refresher-enabled="true",属性:开启自定义下拉刷新
2.2.5、@refresherrefresh="refresher",事件:自定义下拉刷新被触发,可以重新调用接口了
2.2.6、:refresher-triggered="triggered",属性:设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
2.2.7、@refresherrestore="onRestore",事件:自定义下拉刷新被复位
2.2.8、@refresherabort="onAbort",事件:自定义下拉刷新被中止
三、虽然很简单,但是我觉得每个知识点都应该被记录。欢迎交流指正,关注我,一起学习。
四、参考文档:
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/snowball_li/article/details/125962775
边栏推荐
- 路由 知识
- Routing knowledge
- MySQL第三篇
- Fu Yingna: Yuan universe is the new generation of Internet!
- 当我从数据库获取到了winfrom特定的控件ID之后我需要通过这个ID找到对应的控件,并对控件的TEXT文本进行赋值这该怎么做
- 面试必备!TCP协议经典十五连问!
- 2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology
- Is there any way for Youxuan database to check the log volume that the primary cluster transmits to the standby cluster every day?
- 路西法98-生活记录ing
- The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
猜你喜欢

MPU6050

STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案

Design of environment detection system based on STM32 and Alibaba cloud

Typescript from getting started to mastering (XVI) configuration file - first knowledge of compileroptions configuration item

Function pointer and callback function

Configmap configuration and secret encryption

C语言实现三子棋游戏(详解)

Install the laser of ROS_ scan_ Problems encountered in match library (I)

关于双指针的思想总结

The solution of porting stm32f103zet6 program to c8t6+c8t6 download program flash timeout
随机推荐
Object array merges elements according to a field
Const read only variable constant
Note: restframe work records many to one tables, how to serialize in that table (reverse query)
Pointer of pointer???...
数据挖掘——关联分析基础介绍(上)
基于STM32和阿里云的环境检测系统设计
[原理] 横向渗透的几种方式
Mmdetection preliminary use
C语言实现三子棋游戏(详解)
The difference between dynamic, VaR and object in fluent
数据库SQL语句实现数据分解的函数查询
Arrow function of new features of ES6
店铺排名问题,如何解决?
Interview essential! TCP classic 15 consecutive questions!
有一种密码学专用语言叫做ASN.1
Data mining -- Introduction to the basis of association analysis (Part 1)
STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案
Asp. Net MVC, how can the controller in the folder jump to the controller in the root directory?
Ssl== certificate related concepts
Simple cases of inner connection and left connection