這篇文章運用簡單易懂的例子給大家介紹使用uniapp實現可以左右滑動的導航欄,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
<template>
<view>
<home-view></home-view>
<view class="content-box" :id="isScale?'content-box-too':''">
<view class="nav-head-box top-nav-fixed">
<image @click="isScale=!isScale" class="icon-style" src="/static/iconImg/list.png" mode=""></image>
<view class="ft-color-white ft-36 flex-1 flex-wrap align-items-center justify-content-center">
PIQSCORE
</view>
<text class="iconfont icon-UI_icon_shebeisheshi ft-44 ft-color-red"></text>
<text class="iconfont icon-UI_icon_shebeisheshi ft-color-red ft-32 position-absolute"></text>
</view>
<view class="m-top-128 top-nav width-100 pd-f-r-36 ft-color-white flex-nowrap space-between position-relative">
<view v-for="(item,index) in 4" :key="index" @click="currentIndex=index" class="top-nav-item">
ALL
</view>
<view : class="position-absolute top-nav-child"></view>
</view>
<swiper :current="currentIndex" @change="swiperTab">
<swiper-item v-for="(item,index) in list" :key="index">
<view class="width-100 height-100" >
{{index}}
</view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script>
export default{
data(){
return{
isScale:false,
currentIndex:0,
list:["ALL","ALL","ALL","ALL"]
}
},
methods:{
swiperTab(e) {
this.currentIndex = e.detail.current //獲取索引
},
}
}
</script>
<style>
.top-nav{
height: 84upx;
background: #008800;
}
.top-nav-item{
width: 168upx;
line-height: 82upx;
text-align: center;
}
.top-nav-child{
left: 0;
bottom: 0;
width: 164upx;
background: #32B53F;
height: 6upx;
transition: all 0.5s;
}
</style>關于使用uniapp實現可以左右滑動的導航欄就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。