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

微信小程序tabBar用法實(shí)例詳解

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

本文實(shí)例講述了微信小程序tabBar用法。分享給大家供大家參考,具體如下:

1、效果展示

2、原理:在app.json中配置tabBar屬性

{
 "pages": [
  "index",
  "picDisplay"
 ],
 "window": {
  "navigationBarBackgroundColor": "#ffffff",
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "首頁(yè)",
  "backgroundColor": "#eeeeee",
  "backgroundTextStyle": "light",
  "enablePullDownRefresh": false
 },
 "tabBar": {
  "color":"#666666",
  "selectedColor":"#06bd04",
  "list": [{
   "pagePath": "index",
   "text": "首頁(yè)",
   "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": "首頁(yè)",
   "iconPath": "images/index.png",
   "selectedIconPath": "images/indexHL.png"
  },{
   "pagePath": "picDisplay",
   "text": "圖片展示",
   "iconPath": "images/picDisplay.png",
   "selectedIconPath": "images/picDisplayHL.png"
  }]
 }

4、操作方法

新建一個(gè)項(xiàng)目,打開(kāi)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ù)組類(lèi)型,改數(shù)組內(nèi)至少要有兩個(gè)但不大于5個(gè)的tab對(duì)象
  "list": [{
   //設(shè)置tab跳轉(zhuǎn)頁(yè)面鏈接
   "pagePath": "index",
   //設(shè)置tab上的文字
   "text": "首頁(yè)",
   //設(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種常用屬性與配置說(shuō)明:

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)頁(yè)面路徑(該頁(yè)面必須在pages中進(jìn)行了配置

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

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

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

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

相關(guān)文章

最新評(píng)論