用到scroll-view
做下拉,wxml代码如下:
<scroll-view scroll-y lower-threshold="100" bindscrolltolower="scrollToLower" style="height: calc(100vh - 220rpx);" scroll-top="{
{myScrollTop}}">
<view wx:for="{
{memberList}}" wx:key="index">
<view class="name">{
{item.name}}</view>
</view>
</scroll-view>
js代码如下:
data: {
list:[]
noMore:false, // 是否还有数据
isPage:false, // 是否还有下一页
page: 1, // 默认页
size: 10, // 默认每页10条数据
myScrollTop:'' // 滚动条的位置
},
进入页面首次获取数据
onLoad: function (options) {
this.getList()
}
获取并处理数据
getList(isPage) { // 首次调用的时候没有传参isPage为undefined
if(isPage) { // 滑到下一页时isPage