微信小程序 scroll-view滚动到底部事件不触犯的锅

来源:思否 分类: 文章浏览史 发布时间:2020-08-31 10:23:38 最后更新:2020-08-31 浏览:630
转载声明:
本文为摘录自“思否”,版权归原作者所有。
温馨提示:
为了更好的体验,请点击原文链接进行浏览
摘录时间:
2020-08-31 10:23:38

今日准备把微信小程序的下拉刷新做一下,没想到我绑定了bindscrolltolower事件,但是居然不触发,我设置了lower-threshold高度无济于事.最后经过不懈的努力,找了很多资料,才发现,居然要设置scroll-view高度,于是我在.wxss里设置了高度为100%:

.scrollStyle{
   width: 100%;
   height: 100%; 
   display: flex;
  flex-direction: column; 
}

居然无效,修改height为具体高度也无效.
然后我在 style里设置height为200px,居然生效了:

 <scroll-view style='height:{{scrollHeight}}px' class='scrollStyle' scroll-y='true' slot="0" hidden="{{curindex != 0}}" bindscrolltolower="loadMoreData" lower-threshold="100">

注意:style里的height单位必须写px;
scrollHeight怎么来的?是获取了屏幕高度,代码如下:

 let  scrollHeight = wx.getSystemInfoSync().windowHeight;
    this.setData({
      scrollHeight: scrollHeight
    });

scrollHeight其实是减去导航栏和tabbar的高度!
ps:很啃爹只能写在style里才生效.

php技术微信