//首先要在page.json文件里,对应的页面下面加上“"enablePullDownRefresh": true”
{
"path": "*************",
"style": {
"navigationBarTitleText": "****",
"enablePullDownRefresh": true
}
export default {
data() {
return {
rows: [], //通知公告
pageNum: 1,
}
},
onLoad() {
this.getHomeSlideFunc(); //企项管理通知公告
},
onShow() {
this.getHomeSlideFunc(); //企项管理通知公告
},
//触底加载更多
onReachBottom(e) {
console.log("当前页数", this.pageNum)
var add = this.pageNum + 1
this.pageNum = add
let params = {
pageNum: this.pageNum,
pageSize: '10',
}
console.log("当前页码", this.pageNum)
api.get("grid/noticeInfo/list", params, res => {
if (res.code == 200) {
var row = res.rows
var rows = []
var newrows = this.rows.concat(row) //合并操作
this.rows = newrows
} else {
utils.tips(res.msg)
}
})
},
methods: {
getHomeSlideFunc() {
let params = {
pageNum: this.pageNum,
pageSize: '10',
}
console.log("当前页码", this.pageNum)
api.get("grid/noticeInfo/list", params, res => {
if (res.code == 200) {
this.rows = res.rows
} else {
utils.tips(res.msg)
}
})
},
}
}
以上代码就是全部内容,小程序的话,使用自带的下拉触底函数就可以哦,逻辑就是把第一次获取到的数据,和第二次获取到的数组进行合并,合并之后存到数据里,用合并后的来代替最初的数据,这样第三次调用接口,合并的就是前两次的数据