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

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

3D建模师为了让甲方爸爸过稿,还可以这么做,就是在赚血汗钱啊

NebulaGraph v3.2.0 Release Note,对查询最短路径的性能等多处优化

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

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

MySQL的安装与卸载

基于深度学习的路面坑洞检测(详细教程)

【3D建模制作技巧分享】ZBrush模型如何添加不同材质

【内存操作函数内功修炼】memcpy + memmove + memcmp + memset(四)

PID控制器改进笔记之七:改进PID控制器之防超调设定
随机推荐
kernel hung_task死锁检测机制原理实现
未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落
生成回文数
go语言的time包介绍
各行各业都受到重创,游戏行业却如火如荼,如何加入游戏模型师职业
temp7777
[QNX Hypervisor 2.2用户手册]10.5 vdev ioapic
MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
typeScript-闭包函数的使用
仪表板展示 | DataEase看中国:数据呈现中国资本市场
panic: reflect: reflect.Value.SetString using value obtained using unexported field
enumerate()函数
Will we still need browsers in the future?(feat. Maple words Maple language)
深度|医疗行业勒索病毒防治解决方案
七牛云图片上传
node中package解析、npm 命令行npm详解,node中的common模块化,npm、nrm两种方式查看源和切换镜像
Since a new byte of 20K came out, I have seen what the ceiling is
@Import注解的作用以及如何使用
[Paper Notes KDD2021] MixGCF: An Improved Training Method for Graph Neural Network-based Recommender Systems
【3D建模制作技巧分享】如何使用ZBrush导出效果图