当前位置:网站首页>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>
边栏推荐
- 基于Appian低代码平台开发一个SpaceX网站
- 【字符串函数内功修炼】strncpy + strncat + strncmp(二)
- [Cultivation of internal skills of string functions] strncpy + strncat + strncmp (2)
- MySQL的安装与卸载
- App测试和Web测试的区别
- 文章占位 文章占位
- Linear DP (bottom)
- 2022/8/4 树上差分+线段树
- panic: reflect: reflect.Value.SetString using value obtained using unexported field
- 正则表达式绕过
猜你喜欢
![[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)

Day118.尚医通:订单列表、详情、支付

【转载】kill掉垃圾进程(在资源管理器占用的情况下)

MySQL基础篇【聚合函数】

Community Sharing|Tencent Overseas Games builds game security operation capabilities based on JumpServer

各行各业都受到重创,游戏行业却如火如荼,如何加入游戏模型师职业

ffplay视频播放原理分析

为何越来越多人选择进入软件测试行业?深度剖析软件测试的优势...

使用OpenCV实现一个文档自动扫描仪

Kernel函数解析之kernel_restart
随机推荐
【3D建模制作技巧分享】在zbrush中如何雕刻头发 ZBrush头发雕刻小技巧
一点点读懂regulator(二)
对“为什么一些程序员很傲慢”的解读
自从新来了个字节20K出来的,就见识到了什么是天花板
2022年全网最全接口自动化测试框架搭建,没有之一
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
【3D建模制作技巧分享】Maya模型如何导入zbrush
3D建模师为了让甲方爸爸过稿,还可以这么做,就是在赚血汗钱啊
MySQL基础篇【聚合函数】
【游戏建模模型制作全流程】使用ZBrush制作骷髅王
文章占位 文章占位
The Go Programming Language (Introduction)
Go 编程语言(简介)
被领导拒绝涨薪申请,跳槽后怒涨9.5K,这是我的心路历程
软件测试技术之如何编写测试用例(4)
【七夕快乐篇】Nacos是如何实现服务注册功能的?
基于内容的图像检索系统设计与实现--颜色信息--纹理信息--形状信息--PHASH--SHFT特征点的综合检测项目,包含简易版与完整版的源码及数据!
【字符串函数内功修炼】strlen + strstr + strtok + strerror(三)
Vscode连接远程服务器(一套配置成功)
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