這篇文章主要介紹了微信小程序中怎么實現(xiàn)頂部導航欄,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
微信小程序 開發(fā)之頂部導航欄
需求:頂部導航欄
效果圖:
wxml:
{{item}} tab_01 tab_02 tab_03
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 }) } })
運行:
感謝你能夠認真閱讀完這篇文章,希望小編分享的“微信小程序中怎么實現(xiàn)頂部導航欄”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!