当前位置:网站首页>微信小程序下拉刷新功能--onPullDownRefresh
微信小程序下拉刷新功能--onPullDownRefresh
2022-07-16 10:25:00 【前端菜菜DayDayUp】
提到微信小程序的下拉刷新,我们可能首先会想到<scroll-view>中的下拉刷新事件,显而易见这样只满足在<scroll-view>组件。先在我们来看一下onPullDownRefresh下拉刷新功能。详解请见uni-app官网。
onPullDownRefresh
在 js 中定义 onPullDownRefresh 处理函数(和onLoad等生命周期函数同级),监听该页面用户下拉刷新事件。
- 需要在
pages.json里,找到的当前页面的pages节点,并在style选项中开启enablePullDownRefresh。- 当处理完数据刷新后,
uni.stopPullDownRefresh可以停止当前页面的下拉刷新。
uni.startPullDownRefresh(OBJECT)
开始下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
uni.stopPullDownRefresh()
停止当前页面下拉刷新。
示例:
pages.json
{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app",
"enablePullDownRefresh": true
}
}
],
"globalStyle": {
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#0faeff",
"backgroundColor": "#fbf9fe"
}
}index.vue
// 仅做示例,实际开发中延时根据需求来使用。
export default {
data() {
return {
text: 'uni-app'
}
},
onLoad: function (options) {
setTimeout(function () {
console.log('start pulldown');
}, 1000);
uni.startPullDownRefresh();
},
onPullDownRefresh() {
console.log('refresh');
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
}
}我再开发中的使用:
onLoad() {
this.goodsList = [];
const page = {
curPage: 1,
pageSize: 10
}
this.page = page;
uni.startPullDownRefresh();
this.getGoodsList(page);
this.getSwiper();
},
// 下拉刷新
onPullDownRefresh() {
this.goodsList = [];
const page = {
curPage: 1,
pageSize: 10
}
this.page = page;
this.getGoodsList(page);
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1500);
},边栏推荐
- Database and the future of open source
- "Light" is enough to see Xinhua III: how to select all-optical technology in the park - Part 2
- 模拟功放75610诊断功能的调试
- 【今天的小go同学要去丢垃圾(2)】
- 数据库每日一题---第24天:格式化部门表
- 重装mysql后initializing database错误
- 新职业“数据库运行管理员”职业标准启动开发
- 数据库与开源的未来
- Mysql启动选项和配置文件
- The principle and design principle of index
猜你喜欢
随机推荐
AC管理
【深度学习】4 万字笔记!Yann LeCun 深度学习公开课 125 页干货都在这了
Irregular area of OSPF
PG operation and maintenance -- error log and slow log
How JMeter uses MD5 encryption and fingerprint signature on the body
Summary: Prometheus matching pattern
行政处罚法 例外规定
Introduction to Cisco CCNP certification
The professional standard of the new profession "database operation administrator" was launched and developed
module ‘urllib‘ has no attribute ‘urlretrieve‘
脱敏项目的苦乐得失
[today's little go is going to throw away the garbage (3)]
Economic Daily praised Hongji, a leading RPA enterprise, for helping financial institutions with their digital transformation
With "technology as the boat", rpa+ai injects surging momentum into the new retail digital transformation
@Conditional条件装配
速来围观,17个运维实用技巧 ~
可爱的图像分类——《CNN模型中常见的flops到底是什么》一文通解
工业级知识图谱de构建与应用(一):工业级知识图谱概述
【古月21讲】ROS入门系列(3)——客户端Client、服务器Server的编程实现+自定义服务数据编程实现
数据库与开源的未来








