当前位置:网站首页>Uniapp dynamic sliding navigation effect demo (finishing)
Uniapp dynamic sliding navigation effect demo (finishing)
2022-08-04 23:19:00 【I am happy】
效果图:
<template>
<view class="content">
<!-- 导航区域 -->
<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0" enable-flex="true">
<view :class="['scroll-view-item_H',currentTab==index?'active':'']" v-for="(item,index) in navbar"
:key='index' @click="tabClick(index)">{
{
item}}</view>
</scroll-view>
<!-- 内容区域 -->
<swiper class="swiper" :current="currentTab" @change="swiperTab" :style="{height:swiperHeight+'px'}">
<swiper-item>
<view class="swiper-item">
A content navigation, content navigation navigation navigation a content
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
Navigation two navigation two content navigation two content navigation two content
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
Navigation three content navigation navigation three content navigation content
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
Navigation four content navigation navigation four content navigation four content
</view>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
navbar: ['导航一', '导航二', '导航三', '导航四'], //Navigation category
currentTab: 0, //The currently selected navigation category
swiperHeight: 0 //Dynamic givenswiper的高度
}
},
onLoad(option) {
this.swiperHeight = uni.getSystemInfoSync().windowHeight - 25;
console.log(this.swiperHeight);
},
methods: {
tabClick(index) {
this.currentTab = index
},
swiperTab(e) {
this.currentTab = e.detail.current; //获取索引
console.log("this.currentTab", this.currentTab)
}
}
}
</script>
<style lang="less" scoped>
.content {
width: 100%;
.scroll-view_H {
width: 100%;
height: 60rpx;
text-align: center;
line-height: 60rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
overflow: hidden;
.scroll-view-item_H {
flex-shrink: 0;
width: 300rpx;
color: #000000;
font-size: 30rpx;
font-size: bold;
background-color: #EA5149;
letter-spacing: .1em;
text-shadow: 0px 1px 2px #A42B14;
}
.active {
font-size: 40rpx;
color: #55aaff;
}
}
.swiper-item {
height: 100%;
}
}
</style>
边栏推荐
- 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
- 特征工程资料汇总
- 一点点读懂cpufreq(一)
- [Mock Interview - 10 Years of Work] Are more projects an advantage?
- 养殖虚拟仿真软件提供高沉浸式的虚拟场景互动操作体验学习
- 亿流量大考(3):不加机器,如何抗住每天百亿级高并发流量?
- Shell编程之循环语句与函数的使用
- 2022年全网最全接口自动化测试框架搭建,没有之一
- 【3D建模制作技巧分享】ZBrush如何使用Z球
- 仪表板展示 | DataEase看中国:数据呈现中国资本市场
猜你喜欢
4-《PyTorch深度学习实践》-反向传播
MySQL的JSON 数据类型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
Kernel函数解析之kernel_restart
【字符串函数内功修炼】strncpy + strncat + strncmp(二)
「津津乐道播客」#397 厂长来了:怎样用科技给法律赋能?
PID Controller Improvement Notes No. 7: Improve the anti-overshoot setting of the PID controller
2022年全网最全接口自动化测试框架搭建,没有之一
enumerate()函数
[Cultivation of internal skills of string functions] strlen + strstr + strtok + strerror (3)
随机推荐
360市值四年蒸发3900亿,政企安全能救命吗?
Kernel函数解析之kernel_restart
node中package解析、npm 命令行npm详解,node中的common模块化,npm、nrm两种方式查看源和切换镜像
VC bmp文件总结
panic: reflect: reflect.Value.SetString using value obtained using unexported field
质量管理大师爱德华·戴明博士经典的质量管理14条原则
C语言实现扫雷 附带源代码
MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
Day118.尚医通:订单列表、详情、支付
[QNX Hypervisor 2.2用户手册]10.5 vdev ioapic
线性DP(下)
PZK学C语言之字符串函数(一)
typeScript-promise
C5750X7R2E105K230KA(电容器)MSP430F5249IRGCR微控制器资料
golang打开文件和读写文件
go语言的日志实现(打印日志、日志写入文件、日志切割)
中国的顶级黑客在国际上是一个什么样的水平?
3年,从3K涨薪到20k?真是麻雀啄了牛屁股 — 雀食牛逼呀
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
【字符串函数内功修炼】strcpy + strcat + strcmp(一)