本文主要為大家詳細介紹了微信小程式實現tab和swiper切換結合效果,具有一定的參考價值,有興趣的小夥伴們可以參考一下,希望幫助到大家。
本文實例為大家分享了小程式實作tab和swiper切換效果展示的具體程式碼,供大家參考,具體內容如下
先上效果圖:
實作程式碼如下:
wxml 頁面
<scroll-view scroll-x="true" class="weui-navbar"> <block wx:for-items="{{tabs}}"> <view id="{{index}}" class="{{activeIndex == index ?'item_on':''}} default-item" bindtap="tabClick" style="width:{{tabW}}px"> {{item}} </view> </block> <view class="weui-navbar-slider" style="transform:translateX({{slideOffset}}px);"></view> </scroll-view> <view class="rec" /> <swiper current="{{activeIndex}}" class="swiper-box" duration="100" bindchange="bindChange"> <swiper-item class="swiper-item"> <view class="slide-view">tab0</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab1</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab2</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab3</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab4</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab5</view> </swiper-item> <swiper-item class="swiper-item"> <view class="slide-view">tab6</view> </swiper-item> </swiper>
page { height: 100%; } view , scroll-view{ padding: 0px; margin: 0px; } .weui-navbar{ width: 100%; position: fixed; border-bottom: 1px solid #00bba1; box-sizing: border-box; white-space: nowrap; z-index: 100; background: white; } .rec{ width: 100%; height: 7%; } .weui-navbar .default-item{ /*width:25%;*/ display: inline-block; text-align: center; font-size: 32rpx; box-sizing: border-box; height: 7%; padding-bottom: 20rpx; } .weui-navbar .item_on{ color: #00bba1; } .weui-navbar-slider{ position: absolute; width: 160rpx; height: 2px; content:""; background: #00bba1; bottom: 0px; left: 12.5rpx; transition: transform .3s; } .swiper-box{ height: 900px; border-bottom: 1px solid #d1d1d1; } .swiper-box .swiper-item{ text-align: center; padding-top: 200rpx; height: 100%; }######vue swiper實作元件化開發詳解###############微信小程swiper元件實作圖片輪播切換功能教學####### ######微信小程式如何實作頂部普通選項卡非swiper效果的實例######
以上是微信小程式tab和swiper結合效果的實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!