html中
<view v-for="(item,index) in resultList" :key="index" class="item">
</view>
<uni-load-more :status="loadStatus"></uni-load-more>
vue实例中
export default {
data() {
return {
resultList: [],
loadStatus: 'nomore',
params:{
pageNum: 1,
pageSize: 10,
corpcode: '',
corpname: ''
},
pageCount: 0
};
},
//下拉刷新
onPullDownRefresh() {
this.params.pageNum = 1
this.getResultList()
},
//上拉加载更多
onReachBottom(){
if(this.params.pageNum < this.pageCount){
this.params.pageNum += 1
this.getResultList()
}
},
onLoad(query){
if(query.corpcode && query.corpname){
this.params.corpcode = query.corpcode
this.params.corpname = query.corpname
this.getResultList()
}
},
methods:{
getResultList(){
this.loadStatus = 'loading'
this.$api.getERegister(this.params).then(res => {
this.dataHandle(res)
})
},
dataHandle(res){
if(this.params.pageNum === 1){
this.resultList = []
}
this.resultList.push(...res.data.list)
this.pageCount = res.data.pages
if(this.params.pageNum >= this.pageCount){
this.loadStatus = 'nomore'
}else{
this.loadStatus = 'more'
}
uni.stopPullDownRefresh()
}
}
}