微信小程序下拉刷新上拉加载的两种实现方法

  介绍

这篇文章将为大家详细讲解有关微信小程序下拉刷新上拉加载的两种实现方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

微信小程序下拉刷新上拉加载的两种实现方法,

1,利用“onPullDownRefresh"和“onReachBottom"方法实现小程序下拉刷新上拉加载

2,在滚动视图里设定bindscrolltoupper和bindscrolltolower实现微信小程序下拉刷新上拉加载。

1。利用“onPullDownRefresh"和“onReachBottom"方法

在js文件里直接写“onPullDownRefresh"和“onReachBottom"方法即可,xml

& lt; scroll-view  scroll-y =, true 在,,,,   ,,.........   & lt;/scroll-view>

js

onPullDownRefresh:,()函数,{   ,,,//,Do  something  when  pull 下来。   ,,,,console.log(& # 39;刷新& # 39;);   },   ,onReachBottom:函数(),{   ,,,//,Do  something  when  page  reach 底部。   ,,,,console.log (& # 39; circle 下一页& # 39;);   },

2。在滚动视图里设定bindscrolltoupper和bindscrolltolower

在滚动视图里设定bindscrolltoupper和bindscrolltolower,然后在js里写好触发事件后对应的方法。[注意,使用这个模式一定要设置滚动视图的高度,100%不知道为什么设置后没效果,建议使用100 vh) xml

& lt; scroll-view  scroll-y =, true  bindscrolltolower=發oadMore", bindscrolltoupper=皉efesh"比;   ,,..........   & lt;/scroll-view>

js

onPullDownRefresh:,()函数,{   ,,,//,Do  something  when  pull 下来。   ,,,,console.log(& # 39;刷新& # 39;);   },   ,onReachBottom:函数(),{   ,,,//,Do  something  when  page  reach 底部。   ,,,,console.log (& # 39; circle 下一页& # 39;);   },

关于“微信小程序下拉刷新上拉加载的两种实现方法”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看的到。

微信小程序下拉刷新上拉加载的两种实现方法