<view class="List" wx:for="{{List}}">
{{item}}
</view>
data: { List:[],//定义成空数组 currentPage:1, //默认第一页 },
onLoad: function (options) {
this.List()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
// 滚动到页面执行该方法
let that = this
//默认page是第一页 上啦滚动到页面底部页面+1
let currentPage =that.data.currentPage+1
that.setData({
currentPage:currentPage
})
that.List()
},
List: function () {
let that = this
let data = {
page:that.data.currentPage,
row: 6,
}
app.globalData.get(app.globalData.Api.List, data)
.then(res => {
console.log(res)
//用concat把数据连接起来
this.setData({
List:this.data.List.concat(res.ResData.Items)
})
})
.catch(err => {
console.log(err)
})
},