实现防止重复发起请求
首先定义isLoading: false
在每次将要发起请求时将isLoading修改为true,也就是在getGoodsList里面的发送请求之前
等数据加载成功之后将isLoading修改为false
在onReachBottom中判断
if(this.isLoading) return
判断数据是否加载完毕
判断数据是否还有更多
onReachBottom () {
if(this.isLoading) return
// 判断数据时候加载完成
if(this.pagenum*this.pagesize>=this.total) {
return
}
this.pagenum++
this.getGoodsList()
}
定义加载完毕的结构·
-------客观没油了哦-------
.isOver{
height: 70rpx;
border-top:3rpx solid #ccc;
text-align: center;
line-height: 70rpx;
font-size: 30rpx;
color: #ccc;
}
定义hiddenIsOver数据默认为true,控制加载完毕的结构按需显示
-------客观没油了哦-------
当所有数据加载完毕将hiddenIsOver修改为false
onReachBottom () {
if(this.isLoading) return
if(this.pagenum*this.pagesize>=this.total) {
// 当所有数据加载完毕将hiddenIsOver修改为false
return this.hiddenIsOver = false
}
this.pagenum++
this.getGoodsList()
}