1.json文件配置:
2.wxml铺数据
3.js文件,初始化proLst和分页参数
4.onload方法获取第一页数据
onLoad(){
wx.request({
url: `${rootUrl}public/index.php/Jkou/Index/getShoplist?p=0`,
method: 'GET',
header: {
'Accept': 'application/json'
},
success: (res)=>{
if(res.data.length!=0){
this.setData({
proLst:res.data, //给proLst赋值
});
}else{
wx.showToast({
title: '网络错误',
duration:2000,
icon:'none',
})
}
}
})
}
5.onPullDownRefresh方法,上拉刷新时,重新获取数据
6.enablePullDownRefresh方法中,上拉时请求数据
7.获取分页的getData方法:
8.后台分页代码: