学无先后,达者为师

网站首页 编程语言 正文

小程序使用了scroll-view滚动组件时,如何判断滚动的方向

作者:Zan^Z 更新时间: 2022-02-14 编程语言

scroll-view组件里的属性bindscroll
链接: bindscroll.
在这里插入图片描述

//wxml
<scroll-view scroll-y bindscroll="bindscrollfx" class="videoList">
		//内容
</scroll-view>
// js
//判断上下滚动方向)(deltaY小于0时,向下,向上则反之)
  bindscrollfx: function (e) {
    var that = this;
    console.log(e.detail.deltaY);
    var scrollfx=e.detail.deltaY;
    if(scrollfx<0){
      that.setData({
        istrue_scroll:false  //向下滚动
      })
    }else{
      that.setData({
        istrue_scroll:true
      })
    }         
  },

原文链接:https://blog.csdn.net/Zan_Z/article/details/106834054

栏目分类
最近更新