如果想在滚动组件中拿到触底事件需要自己去获取组件,通过bindscrolltolower事件来定义onScrollToLower方法
<scroll-view bindscrolltolower="onScrollToLower" class="my-scroll-view" scroll-y="true" style="height: 100vh;">
<view class="pge">
<view class="list_box" wx:for="{{sendList}}" wx:key="id">
<view class="list_title">
<text>{{item.unit_name}}</text>
</view>
<view class="list_con">
<view class="list_con_text">
<text>科室</text>
<text>{{item.dept_name}}</text>
</view>
</view>
</view>
</view>
</scroll-view>
然后在onScrollToLower方法中通过类来拿到当前高度来判断是否触底
// 滚动组件中监听触底
onScrollToLower: function () {
const query = wx.createSelectorQuery().in(this);
query.select('.my-scroll-view').boundingClientRect((res) => {
if (!res) {
return;
}
const scrollTop = res.top;
const scrollHeight = res.height;
const totalHeight = scrollHeight;
if (scrollTop + scrollHeight >= totalHeight) {
console.log('已到达底部')
}
}).exec()
}