html结构
<div class="main-body" :style="{'-webkit-overflow-scrolling': scrollMode}">
<v-loadmore :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" :auto-fill="false" ref="loadmore">
<template v-for="item in caseList">
<div class="itemBox" style="background: #fff;font-size: 14px;margin: 5px 0">
<div class="title">
<h2 style="line-height: 1.5">案件:<span>{{item.caseNo}}</span></h2>
<a class="btn" href="javascript:;">
{{item.caseStatusName}}
</a>
</div>
<div class="list" @click="showBtn(item)">
<div class="item">
<div class="listItem">
<label>申请人:</label>
<div class="apply">{{item.applicants}}</div>
</div>
<div class="listItem">
<label>案由:</label>
<div>{{item.caseCause}}</div>
</div>
<div class="listItem">
<label>立案日期:</label>
<div>{{item.startDate | setDate }}</div>
</div>
</div>
<div class="item">
<div class="listItem">
<label>被申请人:</label>
<div>{{item.respondents}}</div>
</div>
<div class="listItem">
<label>标的金额:</label>
<div><span>{{item.amtBorrow}}</span>元</div>
</div>
</div>
</div>
<div class="option" v-show='item.show'>
<a class="optionBtn detailsBtn" @click="sqsBtn(item)" href="javascript:;">申请书</a>
<a class="optionBtn rejectBtn" @click="rejectBtn(item)" href="javascript:;">操作记录</a>
<a class="optionBtn adoptBtn" @click="cjsBtn(item)" href="javascript:;">裁决书</a>
</div>
</div>
</template>
</v-loadmore>
</div>
return {
caseList:[],
selected:0,
//分页属性
pageNo:"1",
pageSize:"10"
,
allLoaded: false, //是否可以上拉属性,false可以上拉,true为禁止上拉,就是不让往上划加载数据了
scrollMode:"auto" ,//移动端弹性滚动效果,touch为弹性滚动,auto是非弹性滚动
cjsImg:'',
caseStatus:'',
num:1,
allNum:''
}
mounted(){
this.loadPageList();
},
//方法
loadPageList(){
this.$http.post('/case/list.htm',{
})
.then(response => {
let newData= JSON.parse(pako.inflate(response.data, { to: 'string' }));
this.caseList=newData.result;
this.isHaveMore(this.caseList);
console.log(newData)
for(let i=0;i<this.caseList.length;i++){
this.$set(this.caseList[i],'show',false);
}
this.$nextTick(function () {
this.scrollMode = "touch";
});
}),
more(){
// 分页查询
this.num = parseInt(this.num) + 1;
this.$http.post('/case/list.htm',{
pageNo: this.num,
pageSize:10,
caseStatus:this.caseStatus
})
.then(response => {
let newData= JSON.parse(pako.inflate(response.data, { to: 'string' }));
this.caseList = this.caseList.concat(newData.result);
this.isHaveMore(this.caseList);
this.allNum=newData.count
if(this.allNum>newData.count){
this.allLoaded = true
}
}),
isHaveMore:function(isHaveMore){
// 是否还有下一页,如果没有就禁止上拉刷新
this.allLoaded = true; //true是禁止上拉加载
if(isHaveMore){
this.allLoaded = false;
}
},
这个是看别人博客写的,如何判断我只有5条数据,就拉不动了才对,但是还能在继续拉
首先,从你的代码中我没有看到有任何的可能性会判断禁止上拉刷新。。
其实比较普遍的方法是在more方法(刷新函数)中,通过最后的数量(allNum)与当前页数(num)*单页个数(pageSize)作对比,如果后者更大,则数量不足,不能继续刷新。
大意如此。