微信小程序scroll-view模拟下拉刷新和上拉加载

scroll-view无法下拉刷新和上拉加载。

<scroll-view class="content"  scroll-y="true" scroll-with-animation="true" @touchstart="handleScrollStart"  @touchend="handleScrollEnd"></scroll-view>

handleScrollStart:function(e){
      let _this = this;
      let moveStartY = e.changedTouches[0].pageY;
      _this.moveStartY = moveStartY;
},
 handleScrollEnd:function(e){
       let _this = this;
       let moveEndY =  e.changedTouches[0].pageY;
       
       //下滑
      if(moveEndY - _this.moveStartY > 200){
            uni.startPullDownRefresh();
           ...
      }

   	 //上划
      if( _this.moveStartY - moveEndY > 200 ){
            ...
     }
}

但是这种方法,会导致用户正常地划动页面也触发事件,不太可取。

发布了258 篇原创文章 · 获赞 21 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/wsln_123456/article/details/104613243