当前位置:网站首页>uni-app 顶部选项卡吸附效果 demo(整理)
uni-app 顶部选项卡吸附效果 demo(整理)
2022-08-03 07:49:00 【我是开心呀】
效果图:
<template>
<view>
<!-- 顶部banner图 -->
<view class="ding">banner</view>
<!-- tab 滑动 -->
<view :class="{'st':true,'sticky-fixed':isF}">
<!-- tab部分 -->
<swiper class="ct_tab">
<swiper-item :class="{ 'ct_active': index == tabCur }" v-for="(item, index) in tabList" :key="index"
class="ct_item" @click="clickCtTab(index)">
<text v-text="item.title"></text>
</swiper-item>
</swiper>
</view>
<!-- 内容 -->
<view class="xiala">
<!-- 内容信息 -->
<view v-if="tabCur===0">
<view>全部信息</view>
<view>111111111111111111111111111</view>
<view>222222222222222222222222222</view>
<view>333333333333333333333333333</view>
</view>
<view v-if="tabCur===1">
<view>水果</view>
<view>111111111111111111111111111</view>
<view>222222222222222222222222222</view>
<view>333333333333333333333333333</view>
</view>
<view v-if="tabCur===2">
<view>蔬菜</view>
</view>
<view v-if="tabCur===3">
<view>调味品</view>
</view>
<view v-if="tabCur===4">
<view>肉类</view>
</view>
<view v-if="tabCur===5">
<view>油类</view>
</view>
<view v-if="tabCur===6">
<view>米类</view>
</view>
<view v-if="tabCur===7">
<view>海鲜</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 下拉固定
yuanH: uni.upx2px(200),
isF: false,
// 滑动tab
tabCur: 0,
tabList: [{
title: '全部',
}, {
title: '水果',
}, {
title: '蔬菜',
}, {
title: '调味品',
}, {
title: '肉类',
}, {
title: '油类',
}, {
title: '米类',
}, {
title: '海鲜',
}],
};
},
onPageScroll(e) {
//#ifdef H5
this.isF = true
// #endif
// #ifndef H5
if (this.yuanH > e.scrollTop) {
this.isF = false
} else {
this.isF = true
}
// #endif
},
methods: {
clickCtTab(ctCur) {
this.tabCur = ctCur
console.log('点击了--->' + this.tabCur)
}
},
};
</script>
<style lang='scss' scoped>
/* 顶部 banner */
.ding {
height: 200rpx;
background-color: aquamarine;
}
.st {
height: 90rpx;
width: 750rpx;
background-color: #fff;
z-index: 999;
/* top: 300rpx; */
}
.sticky-fixed {
/* #ifdef H5 */
position: sticky;
top: 44rpx;
/* #endif */
/* #ifndef H5 */
position: fixed;
top: 0;
/* #endif */
z-index: 999;
}
.xiala {
height: 1500px;
background-color: #eee;
padding-top: 100rpx;
}
/* 滑动tab */
.ct_tab {
width: 698rpx;
height: 90rpx;
margin: 0 auto;
/* padding: 30rpx 0; */
font-size: 28rpx;
/* font-weight: bold; */
color: #c0c8d0;
white-space: nowrap;
display: flex;
overflow: hidden;
}
.ct_item {
width: 150rpx;
padding: 20rpx 0;
display: inline-block;
}
.ct_item text {
padding: 20rpx 0;
}
.ct_active {
color: #007AFF;
font-weight: bold;
}
.ct_active text {
border-bottom: 2px solid #007AFF;
}
swiper {
width: 100%;
}
swiper-item {
width: 150rpx !important;
}
</style>
原文链接:https://blog.csdn.net/qq_59795720/article/details/125004913?spm=1001.2014.3001.5502
边栏推荐
- timestamp
- LiveData 记录下 +
- DSP Trick:向量长度估算
- PowerShell:执行 Install-Module 时,不能从 URI 下载
- mysql的innodb存储引擎和myisam存储引擎的区别
- Daily practice of PMP | Do not get lost in the exam-8.2 (including agility + multiple choice)
- 【Kaggle实战】泰坦尼克号生存人数预测(从零到提交到Kaggle再到模型的保存与恢复)
- PostMan使用,访问路径@RequestMapping
- 推荐系统-排序层-模型:Wide&Deep
- sqlite date field plus one day
猜你喜欢
REST学习
- display image API OpenCV 】 【 imshow () to a depth (data type) at different image processing methods
【图像去雾】基于matlab暗通道和非均值滤波图像去雾【含Matlab源码 2011期】
pyspark df secondary sorting
Charles抓包工具学习记录
How to choose a reliable and formal training institution for the exam in September?
Transformer、BERT、GPT 论文精读笔记
AI mid-stage sequence labeling task: three data set construction process records
酷雷曼上新6大功能,全景营销持续加码
进程的创建
随机推荐
pyspark---low frequency feature processing
DSP Trick:向量长度估算
用diskpart的offline命令弹出顽固硬盘
使用pipreqs导出项目所需的requirements.txt(而非整个环境)
Using pipreqs export requirements needed for the project. TXT (rather than the whole environment)
ArcEngine(六)用tool工具实现拉框放大缩小和平移
Logic Pro X自带音色库列表
Taro框架-微信小程序-调用微信支付
ArcEngine(一)加载矢量数据
Docker启动mysql
推荐系统-排序层-特征工程:用户特征、物品特征
Charles抓包工具学习记录
The Transformer, BERT, GPT paper intensive reading notes
面试介绍项目经验(转)
Windows安装MySQL(MIS)
最佳高质量字体
36氪详情页AES
redis AOF持久化个人理解
【云原生--Kubernetes】kubectl命令详解
控制bean的加载