小程序 滚动功能
<scroll-view class='scroll' scroll-y="true" bindscrolltolower="bindscrolltolower">
垂直滚动写入js
// 滚动事件
bindscrolltolower() { if (this.moreData) { this.pageNo++; this.getData(); } }
// 请求网络
const dataList = res.dataList || [];
if (dataList.length != pageSize) {
that.moreData = false;
}
if (that.pageNo > 1) {
dataList = [...that.data.dataList, ...dataList];
}
如果是水平滚动
<scroll-view class='scroll' scroll-x="true" scroll-left="{{scrollLeft}}" > <text bindtap="btn">btn</text> <scroll-view>
handleTab() { const scrollLeft = 100; this.setData({ scrollLeft }) }
如需转载原创文章,请标注原文地址,版权所有!
浙公网安备 33010602011771号