当前位置:网站首页>uniapp横向选项卡(水平滚动导航栏)效果demo(整理)
uniapp横向选项卡(水平滚动导航栏)效果demo(整理)
2022-08-04 23:15:00 【我是开心呀】
效果图:
<!-- 横向选项卡(水平滚动导航栏) -->
<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;
/* 必要,导航栏才能横向*/
border-bottom: 1rpx solid #eee;
text-align: center;
}
.scroll-tab-item {
display: inline-block;
/* 必要,导航栏才能横向*/
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>
边栏推荐
- 社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
- CS8416国产替代DP8416 数字音频接收器
- Since a new byte of 20K came out, I have seen what the ceiling is
- 使用代理对象执行实现类目标方法异常
- go语言的time包介绍
- typeScript-部分应用函数
- [Paper Notes KDD2021] MixGCF: An Improved Training Method for Graph Neural Network-based Recommender Systems
- PZK学C语言之字符串函数(一)
- Will we still need browsers in the future?(feat. Maple words Maple language)
- 【3D建模制作技巧分享】Maya模型如何导入zbrush
猜你喜欢

360市值四年蒸发3900亿,政企安全能救命吗?

Will we still need browsers in the future?(feat. Maple words Maple language)

未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落

enumerate()函数

Since a new byte of 20K came out, I have seen what the ceiling is

Pytorch分布式训练/多卡/多GPU训练DDP的torch.distributed.launch和torchrun

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

【软件测试】常用ADB命令

OPENCV学习DAY8

CS8416国产替代DP8416 数字音频接收器
随机推荐
堪称奔驰“理财产品”,空间媲美宝马X5,采用了非常运动的外观
@Import注解的作用以及如何使用
一点点读懂regulator(二)
【3D建模制作技巧分享】ZBrush模型如何添加不同材质
MySQL的JSON 数据类型1
golang打开文件和读写文件
期货开户哪个平台好,要正规安全的
[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)
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
基于深度学习的路面坑洞检测(详细教程)
【游戏建模模型制作全流程】在ZBrush中雕刻恶魔城男性角色模型
Pytorch分布式训练/多卡/多GPU训练DDP的torch.distributed.launch和torchrun
未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落
Laravel 实现redis分布式锁
Reconfigure the ffmpeg plugin in chrome
go语言的日志实现(打印日志、日志写入文件、日志切割)
测试技术:关于上下文驱动测试的总结
OPENCV学习DAY8
【3D建模制作技巧分享】在zbrush中如何雕刻头发 ZBrush头发雕刻小技巧
一点点读懂cpufreq(一)