当前位置:网站首页>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
边栏推荐
猜你喜欢

The Transformer, BERT, GPT paper intensive reading notes

智能客服,还有多少AI泡沫?
![[Kaggle combat] Prediction of the number of survivors of the Titanic (from zero to submission to Kaggle to model saving and restoration)](/img/2b/d2f565d9221da094a9ccc30f506dc8.png)
[Kaggle combat] Prediction of the number of survivors of the Titanic (from zero to submission to Kaggle to model saving and restoration)

@Async注解的坑,小心

【图像去雾】基于matlab暗通道和非均值滤波图像去雾【含Matlab源码 2011期】

Docker启动mysql

DeFi明斯基时刻:压力测试与启示

Data warehouse buried point system and attribution practice

Evaluate:huggingface评价指标模块入门详细介绍

"Swordsman Offer" brush questions print from 1 to the largest n digits
随机推荐
xshell开启ssh端口转发,通过公网机器访问内网机器
第十二天&接口和协议
训练正常&异常的GAN损失函数loss变化应该是怎么样的
请求与响应:响应
wordpress: 裁剪您的图片时发生错误
WordPress主题-B2美化通用子主题商业运营版
Roson的Qt之旅#104 QML Image控件
SSM整合流程
流行和声基础大笔记
sqlite 日期字段加一天
JS函数获取本月的第一天和最后一天
分治法求解中位数
【图像去噪】基于matlab稀疏表示KSVD图像去噪【含Matlab源码 2016期】
Transformer、BERT、GPT 论文精读笔记
《21天精通TypeScript-5》类型注解与原始类型
pyspark df secondary sorting
Windows安装MySQL(MIS)
Haisi project summary
Logic Pro X built-in sound library list
mysqlbinlog: unknown variable 'default-character-set=utf8'