新聞中心
這篇文章主要介紹了微信小程序如何實(shí)現(xiàn)tabBar,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
具體如下:
1、效果展示
2、原理:在app.json中配置tabBar屬性
{ "pages": [ "index", "picDisplay" ], "window": { "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "首頁", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light", "enablePullDownRefresh": false }, "tabBar": { "color":"#666666", "selectedColor":"#06bd04", "list": [{ "pagePath": "index", "text": "首頁", "iconPath": "images/index.png", "selectedIconPath": "images/indexHL.png" },{ "pagePath": "picDisplay", "text": "圖片展示", "iconPath": "images/picDisplay.png", "selectedIconPath": "images/picDisplayHL.png" }] } }
3、關(guān)鍵代碼
"tabBar": { "color":"#666666", "selectedColor":"#06bd04", "list": [{ "pagePath": "index", "text": "首頁", "iconPath": "images/index.png", "selectedIconPath": "images/indexHL.png" },{ "pagePath": "picDisplay", "text": "圖片展示", "iconPath": "images/picDisplay.png", "selectedIconPath": "images/picDisplayHL.png" }] }
4、操作方法
新建一個(gè)項(xiàng)目,打開app.json文件,將關(guān)鍵代碼復(fù)制到"window":{},后面,注意window的大括號(hào)前加逗號(hào),如下圖
配置tabBar屬性值
"tabBar": { //設(shè)置tabBar文字默認(rèn)顏色 "color":"#666666", //設(shè)置tabBar文字被選中是的顏色 "selectedColor":"#06bd04", //tab列表,數(shù)組類型,改數(shù)組內(nèi)至少要有兩個(gè)但不大于5個(gè)的tab對(duì)象 "list": [{ //設(shè)置tab跳轉(zhuǎn)頁面鏈接 "pagePath": "index", //設(shè)置tab上的文字 "text": "首頁", //設(shè)置tab上的默認(rèn)圖標(biāo) "iconPath": "images/index.png", //設(shè)置tab被選中時(shí)的圖標(biāo) "selectedIconPath": "images/indexHL.png" },{ "pagePath": "picDisplay", "text": "圖片展示", "iconPath": "images/picDisplay.png", "selectedIconPath": "images/picDisplayHL.png" }] }
tabBar的5種常用屬性與配置說明:
1) color:未選擇字體顏色
2) selectedColor:選擇字體顏色
3) borderStyle:tabbar上方線的顏色white(僅支持白色和黑色)
4) backgroundColor:tabbar背景顏色
5) list:設(shè)置rab列表項(xiàng)(最少2個(gè),最多5個(gè)tab)。
另外,list作為數(shù)組屬性,其每一項(xiàng)又是一個(gè)對(duì)象,list可以設(shè)置4種屬性:
① text:設(shè)置tab上的文字
② iconPath:設(shè)置tab處于未激活狀態(tài)時(shí)顯示的圖片路徑。
③ selectedIconPath:設(shè)置tab處于激活狀態(tài)時(shí)的圖片路徑(iconPath與selectedIconPath圖片大小限制都是40KB)
④ pagePath:設(shè)置觸按tab時(shí)的跳轉(zhuǎn)頁面路徑(該頁面必須在pages中進(jìn)行了配置)
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“微信小程序如何實(shí)現(xiàn)tabBar”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司,關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、網(wǎng)站設(shè)計(jì)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁名稱:微信小程序如何實(shí)現(xiàn)tabBar-創(chuàng)新互聯(lián)
本文鏈接:http://www.ef60e0e.cn/article/eiehh.html