<div>
<div class="list" id="list">
<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
<van-list
v-model="loading"
:finished="finished"
@load="onLoad"
:offset="10"
>
<div class="list-item">
<van-cell v-for="(item,key) in list" :key="key" :title="item + '' " />
</div>
</van-list>
</van-pull-refresh>
</div>
</div>
export default {
data(){
return {
list: [],
loading: false,
finished: false,
isLoading: false,
}
},
methods:{
onLoad() {
setTimeout(() => {
for (let i = 0; i < 15; i++) {
this.list.push(this.list.length + 1);
}
this.loading = false;
}, 1000);
},
onRefresh() {
setTimeout(() => {
this.list = [];
this.finished = false;
this.isLoading = false;
this.onLoad()
}, 1000);
}
},
mounted(){
let winHeight = document.documentElement.clientHeight;
document.getElementById(‘list‘).style.height = (winHeight - 50) +‘px‘
}
}
.list{
margin-top:46px;
overflow:scroll;
}
.list-item{
text-align:center;
}