提醒一下:建议把ajax的请求,拆分成一个独立的sdk,避免多处重复代码。
that.loading(false);应该写到ajax执行结束后。
var lhcmDetail=new Vue({
el:'#video-detail',
data:{
loadFlag:false
},
methods:{
loading:function(a){//是否显示加载动画
this.loadFlag=a;
},
judgeLoadMore:function(){//加载更多评论
pageNum++;
var that=this;
that.loading(true);
$.ajax({
url:url,
type:'get',
dataType:'json',
success:function(data){
that.loading(false); //
if(data.length>0){
//do something
}else{
//do something
}
},
error:function(){
that.loading(false); //
}
});
}
}