当前位置:网站首页>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>
边栏推荐
猜你喜欢
随机推荐
当panic或者die被执行时,或者发生未定义指令时,如何被回调到
typeScript-部分应用函数
panic: reflect: reflect.Value.SetString using value obtained using unexported field
Controller层代码这么写,简洁又优雅!
Shell expect real cases
对“为什么一些程序员很傲慢”的解读
OPENCV学习DAY8
MySQL基础篇【聚合函数】
【手撕AHB-APB Bridge】~ AMBA总线 之 AHB
go语言的日志实现(打印日志、日志写入文件、日志切割)
Literature reading ten - Detect Rumors on Twitter by Promoting Information Campaigns with Generative Adversarial Learn
PZK学C语言之字符串函数(一)
The Go Programming Language (Introduction)
PAN3020 Sub-1G无线收发芯片
Laravel 实现redis分布式锁
一点点读懂regulator(三)
基于深度学习的路面坑洞检测(详细教程)
MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
956. 最高的广告牌
特征工程资料汇总









