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

kernel hung_task死锁检测机制原理实现
![[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)](/img/b6/5a1c8b675dc7f67f359c25908403e1.png)
[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)

逆序对的数量

堪称奔驰“理财产品”,空间媲美宝马X5,采用了非常运动的外观

深度|医疗行业勒索病毒防治解决方案

【3D建模制作技巧分享】ZBrush模型制作流程:地精

应用联合、体系化推进。集团型化工企业数字化转型路径
![[Mock Interview - 10 Years of Work] Are more projects an advantage?](/img/fa/2652629d1ff4653aca0d626ac89bf8.jpg)
[Mock Interview - 10 Years of Work] Are more projects an advantage?

If you can't get your heart, use "distributed lock" to lock your people

Pytest学习-Fixture
随机推荐
ffplay视频播放原理分析
Acwing3593. 统计单词
Vscode连接远程服务器(一套配置成功)
Nacos配置中心之客户端长轮询
功耗控制之DVFS介绍
一点点读懂cpufreq(一)
956. 最高的广告牌
话题 | 雾计算和边缘计算有什么区别?
FinClip崁入式搭建生态平台,降低合作门槛
3年,从3K涨薪到20k?真是麻雀啄了牛屁股 — 雀食牛逼呀
MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
基于Appian低代码平台开发一个SpaceX网站
线上虚拟展馆展示具有哪些优势
生产者消费者问题
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
2022/8/3
零基础如何入门软件测试?再到测开(小编心得)
MySQL的安装与卸载
js中小数四则运算精度问题原因及解决办法
[Mock Interview - 10 Years of Work] Are more projects an advantage?