亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序?qū)崿F(xiàn)選項(xiàng)卡的方法

 更新時(shí)間:2022年07月18日 17:04:27   作者:itfallrain  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)選項(xiàng)卡的方法,利用swiper組件實(shí)現(xiàn)選項(xiàng)卡功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)選項(xiàng)卡的具體代碼,供大家參考,具體內(nèi)容如下

微信小程序里沒有自帶選項(xiàng)卡組件,但是卻帶有swiper組件,所以,我們便利用swiper來實(shí)現(xiàn)選項(xiàng)卡的功能。

先看效果圖:

test.wxml

<view class="swiper-tab">
? <view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">一</view>
? <view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">二</view>
? <view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab">三</view>
</view>
?
<swiper class='swi' current="{{currentTab}}" duration="300" bindchange="swiperTab">
? <swiper-item><view>第一屏</view></swiper-item>
? <swiper-item><view>第二屏</view></swiper-item>
? <swiper-item><view>第三屏</view></swiper-item>
</swiper>

test.js

var app=getApp()
Page({
?data:{
? currentTab:0
?},
?onLoad:function(options){
? // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
?
?},
?//滑動(dòng)切換
?swiperTab:function( e ){
? var that=this;
? that.setData({
? ?currentTab:e.detail.current
? });
?},
?//點(diǎn)擊切換
?clickTab: function( e ) {?
?
? var that = this;?
?
? if( this.data.currentTab === e.target.dataset.current ) {?
? ?return false;?
? } else {?
? ?that.setData( {?
? ? currentTab: e.target.dataset.current?
? ?})?
? }?
?}?
?
})

test.wxss

.swi {
? width: 100%;
? height: 100vh;

}
.swiper-tab{
? width: 100%;
? border-bottom: 2rpx solid #ccc;
? text-align: center;
? height: 88rpx;
? line-height: 88rpx;
? font-weight: bold;
}
.swiper-tab-item{
? display: inline-block;
? width: 33.33%;
? color:red;
}
.active{
? color:aqua;
? border-bottom: 4rpx solid red;
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論