小程序 滚动功能

<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
  })
}

 

posted @ 2025-05-09 14:22  微宇宙  阅读(7)  评论(0)    收藏  举报