小程序中tabbar的配置

Posted by PanMin on December 2, 2016

小程序中tabbar的配置

app.js中配置

"tabBar": {
    "backgroundColor": "#f6f6f6",
    "color": "#999",			//tab 上的文字默认颜色
    "selectedColor": "#ff8862", //tab 上的文字选中时的颜色
    "borderStyle": "white",	   //tabbar上边框的颜色, 仅支持 black/white
    "list": [{
        "selectedIconPath": "assets/home-light.png",
        "iconPath": "assets/home.png",
        "pagePath": "pages/index/index",
        "text": "首页"
    },{
        "selectedIconPath": "assets/find-light.png",	//选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效
        "iconPath": "assets/find.png",					//图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片
        "pagePath": "pages/bookCity/bookCity",			//页面路径,必须在 pages 中先定义
        "text": "书城"									//tab 上按钮文字
    },{
        "selectedIconPath": "assets/market-light.png",
        "iconPath": "assets/market.png",
        "pagePath": "pages/bookList/bookList",
        "text": "书单"
    },{
        "selectedIconPath": "assets/more-light.png",
        "iconPath": "assets/more.png",
        "pagePath": "pages/userCenter/userCenter",
        "text": "我的"
    }]
}

注意:

  1. 当设置 position 为 top 时,将不会显示 icon
  2. tabBar 中的 list 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。

属性说明: position:可选值 bottom、top