当前位置:网站首页>vant 标签栏+上拉加载+下拉刷新demo van-tabs+van-pull-refresh+van-list demo
vant 标签栏+上拉加载+下拉刷新demo van-tabs+van-pull-refresh+van-list demo
2022-06-12 12:24:00 【多思考多学习】
思路
页面结构
van-tabs在最上面
van-pull-refresh在van-tabs下面
van-list在van-pull-refresh里面
css关键
给van-pull-refresh设置高度为calc(100% - 44px), 其中44px是van-tabs的高度,
同时给van-pull-refresh设置
overflow: hidden;
overflow-y: scroll;
这样就能滚动起来加载更多
效果展示

以下是正文
html
<div class="AlarmList">
<van-tabs v-model="active" color="RGBA(4, 131, 247, 1)" title-active-color="#000"
@change="onRefresh">
<van-tab v-for="(item,index) in tabList" :key="index" :title="item.title" :name="item.name">
</van-tab>
</van-tabs>
<van-pull-refresh :style="{height:'calc(100% - 44px)'}" v-model="isRefresh"
@refresh="onRefresh" ref="pullRefresh" immediate-check="false">
<van-empty v-if="dataList.length == 0" description="暂无数据" />
<van-list ref="list" class="list" v-model="loadingMore" :finished="finished" finished-text="没有更多了"
@load="onLoadMore">
<div class="list_item" v-for="(item,index) in dataList" :key="index">
div{
{
index}}
</div>
</van-list>
</van-pull-refresh>
</div>
data定义
tabList: [
{
title: "全部",
name: "1"
},
{
title: "人工",
name: '2'
},
{
title: "系统",
name: '3'
},
],
active: '1',
total: 0,
pageNum: 1,
pageSize: 10,
//上拉加载下拉刷新
loadingMore: true, //加载更多是否显示加载中
finished: false, //加载是否已经没有更多数据
isRefresh: false, //是否下拉刷新
dataList: [],
js
//加载页面
initPage() {
this.getList();
},
//刷新
onRefresh() {
this.dataList = [];
this.loadingMore = true;
this.finished = false;
this.isRefresh = false;
this.pageNum = 1;
this.getList();
},
//加载更多
onLoadMore() {
this.pageNum++;
setTimeout(() => {
this.getList();
}, 200);
},
// 获取列表
getList() {
setTimeout(() => {
let list = []
for (let index = 0; index < 5; index++) {
let obj = {
name:"测试",id:index}
list.push(obj)
}
// 加载状态结束
this.loadingMore = false;
this.isRefresh = false;
if (this.dataList.length > 10) {
//没有更多了
this.finished = true;
}
//数据追加到列表
this.dataList = this.dataList.concat(list);
}, 1000);
},
css
.AlarmList{
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
position: relative;
/deep/ .van-tabs {
// height: 100%;
.van-tabs__content {
height: calc(100% - 44px);
}
.van-tab__pane {
height: 100%;
}
}
.van-pull-refresh {
overflow: hidden;
overflow-y: scroll;
.list_item {
width: calc(100% - 0.6rem);
display: flex;
align-items: center;
margin: 0.3rem;
box-sizing: border-box;
background-color: #fff;
border-radius: 4px;
flex-direction: column;
height: 4rem;
}
}
}
边栏推荐
- Vim,Gcc,Gdb
- 2021-11-16
- MySQL 分区表介绍与测试
- 安装canvas遇到的问题和运行项目遇到的报错
- Ros- resolve error "tf2\u buffer\was not declared in this scope"
- [transfer]placement NEW
- SWI-Prolog的下载与使用
- Matlab install license manager error -8
- Start with Xiaobai, take the weight parameter from the trained model and draw the histogram
- 無重複字符的最長字符串(LeetCode 3)
猜你喜欢

Principle of master-slave replication of redis

In depth anatomy of C language - key words & supplementary contents

JS built in object

安装canvas遇到的问题和运行项目遇到的报错

golang的channel和条件变量在单生产单消费场景下的性能对比测试

左右案例+小圆点的轮播图+无时间

Longest string without duplicate characters (leetcode 3)

Reasons for college students' leave

Dom+js+ carousel map + no time

Redis的主从复制原理
随机推荐
Performance comparison test of channel and condition variables of golang in single production and single consumption scenarios
ACE配置IPv6, VS静态编译ACE库
TRON-api-波场转账查询接口-PHP版本-基于ThinkPHP5封装-附带接口文档-20220528版本
stress - 系统压力模拟工具
BAT面试&高级进阶,文末领取面试资料
回溯法, 八皇后
JS attribute operation and node operation
KDD2022 | 边信息增强图Transformer
Decision tree of machine learning
Bank layout meta universe: digital collections, digital employees become the main track!
从小白入手,从已经训练好的模型中取出weight权重参数绘制柱状图
Bat interview & advanced, get interview materials at the end of the text
this的指向
What is modularity? Benefits of modularity
Principle of master-slave replication of redis
SWI-Prolog的下载与使用
JS string array converted to numeric array and how to add the numbers in the array
About message
無重複字符的最長字符串(LeetCode 3)
[transfer]placement NEW