当前位置:网站首页>uniapp horizontal tab (horizontal scrolling navigation bar) effect demo (organization)
uniapp horizontal tab (horizontal scrolling navigation bar) effect demo (organization)
2022-08-04 23:19:00 【I am happy】
效果图:
<!-- horizontal tab(Scrolls the navigation bar horizontally) -->
<template>
<view>
<!-- 顶部导航栏 -->
<view class="horizonal-tab">
<scroll-view scroll-x="true" scroll-with-animation class="scroll-tab">
<block v-for="(item,index) in tabBars" :key="index">
<view class="scroll-tab-item" :class="{'active': tabIndex==index}" @tap="toggleTab(index)">
{
{
item.name}}
<view class="scroll-tab-line"></view>
</view>
</block>
</scroll-view>
</view>
<!-- 内容区 -->
<view class="content">
<!-- 滑块视图 -->
<swiper :current="tabIndex" @change="tabChange">
<!-- current:当前所在滑块的index -->
<swiper-item v-for="(content,index) in contentList" :key="index">
<view class="content">{
{
content}}</view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script>
export default {
data() {
return {
tabIndex: 0,
/* 选中标签栏的序列,默认显示第一个 */
contentList: [
"关注",
"推荐",
"热点",
"体育",
'财经',
'娱乐',
'哈',
'哈1',
'哈2',
'哈3',
],
tabBars: [{
name: '关注',
id: 'guanzhu'
},
{
name: '推荐',
id: 'tuijian'
},
{
name: '热点',
id: 'redian'
},
{
name: '体育',
id: 'tiyu'
},
{
name: '财经',
id: 'caijing'
},
{
name: '娱乐',
id: 'yule'
},
{
name: '哈',
id: 'ha'
},
{
name: '哈1',
id: 'ha1'
},
{
name: '哈2',
id: 'ha2'
},
{
name: '哈3',
id: 'ha3'
}
]
}
},
methods: {
//切换选项卡
toggleTab(index) {
this.tabIndex = index;
},
//滑动切换swiper
tabChange(e) {
console.log(e);
this.tabIndex = e.detail.current;
}
}
}
</script>
<style>
.horizonal-tab {
}
.horizonal-tab .active {
color: red;
}
.scroll-tab {
white-space: nowrap;
/* 必要,The navigation bar can only be horizontal*/
border-bottom: 1rpx solid #eee;
text-align: center;
}
.scroll-tab-item {
display: inline-block;
/* 必要,The navigation bar can only be horizontal*/
margin: 20rpx 30rpx 0 30rpx;
}
.active .scroll-tab-line {
border-bottom: 5rpx solid red;
border-top: 5rpx solid red;
border-radius: 20rpx;
width: 70rpx;
}
</style>
边栏推荐
- 基于内容的图像检索系统设计与实现--颜色信息--纹理信息--形状信息--PHASH--SHFT特征点的综合检测项目,包含简易版与完整版的源码及数据!
- 【游戏建模模型制作全流程】使用ZBrush制作骷髅王
- typeScript-promise
- [QNX Hypervisor 2.2用户手册]10.6 vdev mc146818
- OPENCV学习DAY8
- MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
- 线上虚拟展馆展示具有哪些优势
- 对“为什么一些程序员很傲慢”的解读
- [Cultivation of internal skills of string functions] strncpy + strncat + strncmp (2)
- 注解@EnableAutoConfiguration的作用以及如何使用
猜你喜欢
golang打开文件和读写文件
SRv6网络的安全解决方案
亿流量大考(3):不加机器,如何抗住每天百亿级高并发流量?
轮播图动态渲染
未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落
应用联合、体系化推进。集团型化工企业数字化转型路径
【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
未来我们还需要浏览器吗?(feat. 枫言枫语)
[Cultivation of internal skills of string functions] strlen + strstr + strtok + strerror (3)
基于内容的图像检索系统设计与实现--颜色信息--纹理信息--形状信息--PHASH--SHFT特征点的综合检测项目,包含简易版与完整版的源码及数据!
随机推荐
【转载】kill掉垃圾进程(在资源管理器占用的情况下)
Since a new byte of 20K came out, I have seen what the ceiling is
I was rejected by the leader for a salary increase, and my anger rose by 9.5K after switching jobs. This is my mental journey
The Record of Reminding myself
特征工程资料汇总
亿流量大考(3):不加机器,如何抗住每天百亿级高并发流量?
正则表达式绕过
【3D建模制作技巧分享】ZBrush如何重新拓扑
To Offer | 03. Repeat Numbers in the array
未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落
SRv6网络的安全解决方案
Service Mesh落地路径
[Mock Interview - 10 Years of Work] Are more projects an advantage?
@Import注解的作用以及如何使用
一点点读懂Thremal(二)
C5750X7R2E105K230KA(电容器)MSP430F5249IRGCR微控制器资料
地面高度检测/平面提取与检测(Fast Plane Extraction in Organized Point Clouds Using Agglomerative Hierarchical Clu)
直接插入排序
Kernel函数解析之kernel_restart
Qt中的常用控件