微信小程式tabBar用法執行個體詳解,小程式tabbar

來源:互聯網
上載者:User

小程式tabBar用法執行個體詳解,小程式tabbar

本文執行個體講述了小程式tabBar用法。分享給大家供大家參考,具體如下:

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、關鍵代碼

"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、操作方法

建立一個項目,開啟app.json檔案,將關鍵代碼複製到"window":{},後面,注意window的大括弧前加逗號,如

配置tabBar屬性值

"tabBar": {  //設定tabBar文字預設顏色  "color":"#666666",  //設定tabBar文字被選中是的顏色  "selectedColor":"#06bd04",  //tab列表,數群組類型,改數組內至少要有兩個但不大於5個的tab對象  "list": [{   //設定tab跳轉頁面連結   "pagePath": "index",   //設定tab上的文字   "text": "首頁",   //設定tab上的預設表徵圖   "iconPath": "images/index.png",   //設定tab被選中時的表徵圖   "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:設定rab清單項目(最少2個,最多5個tab)。

另外,list作為數組屬性,其每一項又是一個對象,list可以設定4種屬性:

① text:設定tab上的文字

② iconPath:設定tab處於未啟用狀態時顯示的圖片路徑。

③ selectedIconPath:設定tab處於啟用狀態時的圖片路徑(iconPath與selectedIconPath圖片大小限制都是40KB)

④ pagePath:設定觸按tab時的跳轉頁面路徑(該頁面必須在pages中進行了配置)

5、完整執行個體代碼點擊此處本站下載

此外,小程式開發軟體如下:

https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html?t=201714

希望本文所述對大家小程式開發有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.