欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ionic實(shí)現(xiàn)可滑動(dòng)的tab選項(xiàng)卡切換效果

 更新時(shí)間:2020年04月15日 16:37:48   作者:lishihong108  
這篇文章主要為大家詳細(xì)介紹了ionic實(shí)現(xiàn)可滑動(dòng)的tab選項(xiàng)卡切換效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

利用ionic的slide-box組件實(shí)現(xiàn)可滑動(dòng)的tab,主要是監(jiān)聽(tīng)tab點(diǎn)擊以及slide頁(yè)面滑動(dòng)的事件,做相應(yīng)的處理,用ng-repeat循環(huán),優(yōu)化、簡(jiǎn)略了代碼,有需要的同學(xué)可以看看。

先來(lái)張效果圖:

用到的css代碼:

.tab_default{ 
 border-bottom:solid 1px #F2F2F2;
 padding:6px 0;
}
.tab_select{
 border-bottom:solid 1px #3E89F5;
 box-shadow:0 -3px 8px #C1D3F0 inset;
}
.arrow-top {
 position: absolute;
 width: 0;
 height: 0; 
 top:20px; 
 border: 6px solid #3E89F5;
 border-right-color:transparent;
 border-left-color: transparent;
 border-top-color: transparent;
}
.arrow-top:after {
 content:'';
 position:absolute;
 width: 0;
 height: 0; 
 border: 12px solid #fff;
 right: -12px;
 bottom: -13px;
 border-right-color:transparent;
 border-left-color: transparent;
 border-top-color: transparent;
}

頁(yè)面上html代碼:

<ion-view view-title="滑動(dòng)tab"> 
 <ion-content has-bouncing="false">
 <div style="display:flex;width:100%;">
 <div style="flex:1;text-align: center;" class="tab_default" ng-repeat="d in tabNames" ng-click="activeSlide($index)" ng-class="slectIndex==$index ? 'tab_select' : '' ">
 {vvxyksv9kd}
 <div class="arrow-top" style="left:{{15+$index*33}}%" ng-show="slectIndex==$index"></div>
 </div> 
 </div> 
 <ion-slide-box on-slide-changed="slideChanged(index)" active-slide="slideIndex" does-continue="false" show-pager="false">
 <ion-slide ng-repeat="p in pages">
 <div ng-include="p"></div>
 </ion-slide>
 </ion-slide-box>
 </ion-content>
</ion-view>

對(duì)應(yīng)的controller.js代碼:

$scope.tabNames=['java','html5','android'];
$scope.slectIndex=0;
$scope.activeSlide=function(index){//點(diǎn)擊時(shí)候觸發(fā)
 $scope.slectIndex=index;
 $ionicSlideBoxDelegate.slide(index);
};
$scope.slideChanged=function(index){//滑動(dòng)時(shí)候觸發(fā)
 $scope.slectIndex=index;
};
$scope.pages=["templates/tab01.html","templates/tab02.html","templates/tab03.html"];

tab01.html、tab02.html、tab03.html這幾個(gè)都是差不多的,貼一個(gè)tab01的:

<div style="width:100%;text-align: center;padding-top:30px;">
 page 01
 <p style="margin-top:30px;">
 <img src="img/tab01.jpg" style="width:100%;"/>
 </p>
</div>

注意點(diǎn):

•點(diǎn)擊時(shí)候?qū)?dāng)前循環(huán)的索引$index賦值給變量slideIndex,在tab中使用ng-class判斷點(diǎn)擊時(shí)候的索引和slideIndex是否一樣,一樣則改變相應(yīng)的tab的樣式;

•滑動(dòng)的時(shí)候是用的slide-box的一個(gè)函數(shù),on-slide-changed,當(dāng)slide頁(yè)面發(fā)發(fā)生變化的時(shí)候,會(huì)向改函數(shù)傳遞一個(gè)變量index標(biāo)識(shí)當(dāng)前slide的索引;

•如果不想滾動(dòng)只點(diǎn)擊,可以去掉on-slide-changed的監(jiān)聽(tīng),也可以增加一個(gè)屬性,disable-scroll="true",禁止slide page滾動(dòng);

如果大家還想深入學(xué)習(xí),可以點(diǎn)擊兩個(gè)精彩的專題:javascript選項(xiàng)卡操作方法匯總 jquery選項(xiàng)卡操作方法匯總

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

相關(guān)文章

最新評(píng)論