写懒加载时候要注意当前页面能不能删除数据(删除后还是显示原来这么多的数据)

就是懒加载的页面里可以删除数据的时候,因为删除以后一般会重新获取数据,如果懒加载直接写在getData里就无法加载回原来的所有内容,这对用户体验不好
有删除时候写法在下面:
<ul v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="30"></ul>


mounted: function(){
this.loadMore()
},


//页面一开始执行这个页面
loadMore:function(){
this.busy = true;
this.loading = false;
this.$http.get('/marketing/getClientVoucher?clientID='+ this.clientID+'&state='+this.state+'&page='+this.page+'&num='+this.num).then(res=>{
//不足一页  不在触发滚动加载
if(res.data && res.data.length>=this.num){
this.busy = false
this.loading = true;
}else{
          this.loading = false;
        }
if(res.data){
for(var i=0;i<res.data.length;i++){
res.data[i]['fdmPrice'] = parseFloat(res.data[i]['fdmPrice'])
res.data[i]['fdmOldPrice'] = parseFloat(res.data[i]['fdmOldPrice'])
}
this.myList = this.page==1?(res.data||[]):this.myList.concat((res.data||[]))
}else{
if(this.myList.length==0){
    this.dataNull = true
    }else{
    this.dataNull = false
    }
}
this.page++
})
},


    //删除后用这获取数据
    getClientVoucher:function(){
this.$http.get('/marketing/getClientVoucher?clientID='+ this.clientID+'&state='+this.state+'&page=1'+'&num='+(this.page-1)*this.num).then(res=>{
if(res.data){
for(var i=0;i<res.data.length;i++){
res.data[i]['fdmPrice'] = parseFloat(res.data[i]['fdmPrice'])
res.data[i]['fdmOldPrice'] = parseFloat(res.data[i]['fdmOldPrice'])
}
this.myList =res.data
}else{
this.myList = []
if(this.myList.length==0){
    this.dataNull = true
    }else{
    this.dataNull = false
    }
}
})
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值