就是懒加载的页面里可以删除数据的时候,因为删除以后一般会重新获取数据,如果懒加载直接写在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
}
}
})
},
有删除时候写法在下面:
<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
}
}
})
},