当前位置:网站首页>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;
}
}
}
边栏推荐
- Performance comparison test of channel and condition variables of golang in single production and single consumption scenarios
- Stress - system pressure simulation tool
- imx6-uboot添加lvds1显示
- Easy to use assistant tools and websites
- [transfer]placement NEW
- Cocktail sort
- 点云配准--gicp原理与其在pcl中的使用
- Dom+js+ carousel map + no time
- Redis的主从复制原理
- 开源项目-(ERP+酒店+电商)后台管理系统
猜你喜欢

Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference

【Leetcode】221. Largest Square

WebStorage

【C语言】关键字static&&多文件&&猜字游戏

Dom and BOM in JS

JS string array converted to numeric array and how to add the numbers in the array

Redis的主从复制原理

Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference

7-5 complex quaternion operation

This direction of ordinary function and arrow function
随机推荐
【Leetcode】199. Right view of binary tree
JS built in object
A. Prefix range
Pre order, middle order and post order traversal of tree
Advantages and disadvantages of single page development and multi page development
[转]placement new
Left and right cases + rotating pictures of small dots + no time
你不会只会用console.log()吧?
【Leetcode】221. Largest Square
A short guide to SSH port forwarding
从小白入手,从已经训练好的模型中取出weight权重参数绘制柱状图
左右案例+小圆点的轮播图+无时间
点云配准--gicp原理与其在pcl中的使用
[译] Go语言测试进阶版建议与技巧
Bat interview & advanced, get interview materials at the end of the text
Video speed doubling in PC browser
[译] Go References - The Go Memory Model | golang官方文档中文翻译之内存模型
The advantages of saving pointers when saving objects with vector and the use of reserve
Take the web page animation effects that can be used. Don't you come and have a look?
MySQL 分区表介绍与测试