微信小程序 開發(fā)之頂部導(dǎo)航欄實(shí)例代碼
更新時間:2017年02月23日 15:55:42 投稿:lqh
這篇文章主要介紹了微信小程序 開發(fā)之頂部導(dǎo)航欄實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
微信小程序 開發(fā)之頂部導(dǎo)航欄
需求:頂部導(dǎo)航欄
效果圖:
wxml:
<!--導(dǎo)航條--> <view class="navbar"> <text wx:for="{{navbar}}" data-idx="{{index}}" class="item {{currentTab==index ? 'active' : ''}}" wx:key="unique" bindtap="navbarTap">{{item}}</text> </view> <!--首頁--> <view hidden="{{currentTab!==0}}"> tab_01 </view> <!--搜索--> <view hidden="{{currentTab!==1}}"> tab_02 </view> <!--我--> <view hidden="{{currentTab!==2}}"> tab_03 </view>
wxss:
page{ display: flex; flex-direction: column; height: 100%; } .navbar{ flex: none; display: flex; background: #fff; } .navbar .item{ position: relative; flex: auto; text-align: center; line-height: 80rpx; } .navbar .item.active{ color: #FFCC00; } .navbar .item.active:after{ content: ""; display: block; position: absolute; bottom: 0; left: 0; right: 0; height: 4rpx; background: #FFCC00; }
js:
var app = getApp() Page({ data: { navbar: ['首頁', '搜索', '我'], currentTab: 0 }, navbarTap: function(e){ this.setData({ currentTab: e.currentTarget.dataset.idx }) } })
運(yùn)行:
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
- 微信小程序教程系列之設(shè)置標(biāo)題欄和導(dǎo)航欄(7)
- 詳解微信小程序設(shè)置底部導(dǎo)航欄目方法
- 微信小程序自定義頭部導(dǎo)航欄和導(dǎo)航欄背景圖片 navigationStyle問題
- 微信小程序頂部導(dǎo)航欄滑動tab效果
- 詳解微信小程序膠囊按鈕返回|首頁自定義導(dǎo)航欄功能
- 微信小程序中頂部導(dǎo)航欄的實(shí)現(xiàn)代碼
- 微信小程序自定義navigationBar頂部導(dǎo)航欄適配所有機(jī)型(附完整案例)
- 微信小程序?qū)崙?zhàn)之頂部導(dǎo)航欄(選項(xiàng)卡)(1)
- 微信小程序?qū)崿F(xiàn)左側(cè)滑動導(dǎo)航欄
- 微信小程序?qū)崿F(xiàn)左側(cè)導(dǎo)航欄
相關(guān)文章
Hardhat進(jìn)行合約測試環(huán)境準(zhǔn)備及方法詳解
這篇文章主要為大家介紹了Hardhat進(jìn)行合約測試環(huán)境準(zhǔn)備及方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03微信小程序 (三)tabBar底部導(dǎo)航詳細(xì)介紹
這篇文章主要介紹了微信小程序 (三)tabBar底部導(dǎo)航詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2016-09-09微信小程序報(bào)錯:this.setData is not a function的解決辦法
這篇文章主要介紹了微信小程序報(bào)錯:this.setData is not a function的解決辦法的相關(guān)資料,希望通過本文能幫助到大家解決這樣類似的問題,需要的朋友可以參考下2017-09-09JavaScript使用JSON.stringify()方法帶參及不帶參示例詳解
這篇文章主要介紹了JavaScript使用JSON.stringify()方法帶參及不帶參示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07