数据加载完之后显示没有更多数据

This commit is contained in:
2023-08-28 14:18:17 +08:00
parent a15c7d568d
commit a50dde13a1

View File

@ -1,5 +1,5 @@
<template>
<div class="wrap" @scroll="handleScroll">
<div class="wrap" >
<div class="navBar">
<van-nav-bar
title="车辆管理"
@ -19,6 +19,12 @@
</van-nav-bar>
</div>
<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
<van-list
v-model="loading1"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<div class="carItem" v-for="(item,index) in vehicleList" :key="index">
<div class="carCode">
<div class="codeLeft">{{item.plateNumber}} / {{item.vehicleTypeString}}</div>
@ -33,6 +39,8 @@
<span :class="item.hasPolymerization.code == 0 ? 'isYes' :'isNo'">{{item.hasPolymerization.label}}</span>
</div>
</div>
</van-list>
</van-pull-refresh>
<van-dialog v-model="show" title="确定删除吗" show-cancel-button @confirm="handleConfirm"></van-dialog>
<div v-if="loading">加载中...</div>
@ -56,12 +64,24 @@ export default {
total:'',
loading:false,
isLoading: false,
loading1: false,
finished: false
}
},
mounted() {
this.getVehicleList();
},
methods:{
async onLoad(){
this.pageNum++;
await this.getVehicleList()
// 加载状态结束
this.loading1 = false;
// 数据全部加载完成
if (this.vehicleList.length >= this.total) {
this.finished = true;
}
},
onRefresh() {
this.getVehicleList()
setTimeout(() => {
@ -74,7 +94,6 @@ export default {
pageNum:this.pageNum,
pageSize:this.pageSize
})
// if(result.code === 200){
this.total=result.total
if(this.pageNum == 1){// 第一页直接赋值
this.vehicleList=result.data;
@ -83,7 +102,6 @@ export default {
let arr = result.data;
this.vehicleList = preList.concat(arr)
}
// }
},
deleteItem(id){//删除车辆
this.show=true
@ -112,6 +130,7 @@ export default {
let num = Math.ceil( this.total / 10)
if(num <= this.pageNum){
// console.log("不在加载数据")
}else{
this.pageNum++;
await this.getVehicleList()