欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序tabBar用法實例詳解

 更新時間:2017年12月04日 10:29:57   作者:FutrueJet  
這篇文章主要介紹了微信小程序tabBar用法,結(jié)合實例形式詳細(xì)分析了微信小程序中tabBar的功能、配置項使用方法與操作注意事項,并附帶完整demo源碼供讀者下載參考,需要的朋友可以參考下

本文實例講述了微信小程序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、關(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、操作方法

新建一個項目,打開app.json文件,將關(guān)鍵代碼復(fù)制到"window":{},后面,注意window的大括號前加逗號,如下圖

配置tabBar屬性值

"tabBar": {
  //設(shè)置tabBar文字默認(rèn)顏色
  "color":"#666666",
  //設(shè)置tabBar文字被選中是的顏色
  "selectedColor":"#06bd04",
  //tab列表,數(shù)組類型,改數(shù)組內(nèi)至少要有兩個但不大于5個的tab對象
  "list": [{
   //設(shè)置tab跳轉(zhuǎn)頁面鏈接
   "pagePath": "index",
   //設(shè)置tab上的文字
   "text": "首頁",
   //設(shè)置tab上的默認(rèn)圖標(biāo)
   "iconPath": "images/index.png",
   //設(shè)置tab被選中時的圖標(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列表項(最少2個,最多5個tab)。

另外,list作為數(shù)組屬性,其每一項又是一個對象,list可以設(shè)置4種屬性:

text:設(shè)置tab上的文字

iconPath:設(shè)置tab處于未激活狀態(tài)時顯示的圖片路徑。

selectedIconPath:設(shè)置tab處于激活狀態(tài)時的圖片路徑(iconPath與selectedIconPath圖片大小限制都是40KB

pagePath:設(shè)置觸按tab時的跳轉(zhuǎn)頁面路徑(該頁面必須在pages中進(jìn)行了配置

5、完整實例代碼點(diǎn)擊此處本站下載。

此外,微信小程序開發(fā)軟件下載地址如下:

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

希望本文所述對大家微信小程序開發(fā)有所幫助。

相關(guān)文章

最新評論