ホームページ  >  記事  >  ウェブフロントエンド  >  WeChat アプレット ナビゲーション バーのタブ効果を実装する方法

WeChat アプレット ナビゲーション バーのタブ効果を実装する方法

小云云
小云云オリジナル
2018-05-14 11:09:254030ブラウズ

この記事は主にナビゲーションバーのタブ効果を実現するためのWeChatアプレットを詳しく紹介していますので、興味のある方は参考にしていただければ幸いです。

レンダリング

WXML

<import src="../../template/list.wxml"/>

<view class="tui-tabbar-content">
 <view class="tui-tabbar-group">
  <text data-id="0" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 0 ? &#39;tui-active&#39; : &#39;&#39;}}">已获得赏金</text>
  <text data-id="1" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 1 ? &#39;tui-active&#39; : &#39;&#39;}}">赏金在路上</text>
  <text data-id="2" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 2 ? &#39;tui-active&#39; : &#39;&#39;}}">邀请失败</text>
 </view>
</view>
<view class="tui-list-box {{index == 0 ? &#39;&#39; : &#39;tui-hide&#39;}}">
 <template wx:for="{{[&#39;选项卡一子选项 - 1&#39;,&#39;选项卡一子选项 - 2&#39;,&#39;选项卡一子选项 - 3&#39;,&#39;选项卡一子选项 - 4&#39;,&#39;选项卡一子选项 - 5&#39;,&#39;选项卡一子选项 - 6&#39;,&#39;选项卡一子选项 - 7&#39;,&#39;选项卡一子选项 - 8&#39;]}}" is="listNoneOnly" data="{{item}}"></template>
</view>
<view class="tui-list-box {{index == 1 ? &#39;&#39; : &#39;tui-hide&#39;}}">
 <template wx:for="{{[&#39;选项卡二子选项 - 1&#39;,&#39;选项卡二子选项 - 2&#39;,&#39;选项卡二子选项 - 3&#39;,&#39;选项卡二子选项 - 4&#39;,&#39;选项卡二子选项 - 5&#39;]}}" is="listNoneOnly" data="{{item}}"></template>
</view>
<view class="tui-list-box {{index == 2 ? &#39;&#39; : &#39;tui-hide&#39;}}">
 <template wx:for="{{[&#39;选项卡三子选项 - 1&#39;,&#39;选项卡三子选项 - 2&#39;,&#39;选项卡三子选项 - 3&#39;]}}" is="listNoneOnly" data="{{item}}"></template>
</view>

WXSS

page{background-color: #efeff4;}
.tui-tabbar-content{
 padding: 10px;
}
.tui-tabbar-group{
 border: 1px solid #4cd964;
 border-radius: 3px;
 overflow: hidden;
 width: 100%;
 display: table;
 table-layout: fixed;
 color: #4cd964;
}
.tui-tabbar-cell{
 display: table-cell;
 width: 100%;
 height: 80rpx;
 line-height: 80rpx;
 font-size: 35rpx;
 text-align: center;
}
.tui-tabbar-cell:not(:last-child){border-right: 1px solid #4cd964;}
.tui-tabbar-cell.tui-active{background-color: #4cd964;color: #fff;}

.tui-list-box{border-top:1px solid #c8c7cc;}

JS

Page({
 data: {
  index: 0
 },
 changeTabbar(e){
  this.setData({ index: e.currentTarget.dataset.id})
 }
})

概要

WeChatアプレットの切り替えは、特定の値の判断を使用してリストとタブバーを切り替えます。

関連する推奨事項:

WeChat アプレット YDUI の ScrollTab コンポーネントのスクロール タブ効果の詳細な説明

タブ機能を実装する 2 つの jQuery メソッド

jQuery モバイル タブのタブ効果を実装するメソッド

以上がWeChat アプレット ナビゲーション バーのタブ効果を実装する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。