微信小程序全局配置:pages、window、tabBar

微信小程序全局配置文件app.json,最基本的配置项有:pages、window、tabBar。window界面最上面的标题部分,pages界面中间的内容部分,tabBar界面最下面的菜单栏。

window

值为字典,常用属性:navigationBarBackgroundColor(背景颜色,只能是RGB16色)、navigationBarTextStyle(字体颜色,只能是black/white)、navigationBarTitleText(标题内容,只能是字符串)。

pages

值为列表,存储字符串的页面路径。

tabBar

值为字典,常用属性:list(菜单列表,1个字典表示1个菜单)、selectedColor(选中菜单的颜色,只能是RGB16色)。list以字典值存储页面,每个页面的常用属性有:pagePath(页面路径)、text(菜单标题)、iconPath(菜单图标)、selectedIconPath(菜单被选中后图标)。


样例代码:

{

  "pages": [

    "pages/index/index",

    "pages/home/home"

  ],

  "window": {

    "navigationBarBackgroundColor": "#DCDCDC",

    "navigationBarTextStyle": "black",

    "navigationBarTitleText": "李业"

  },

  "tabBar": {

    "selectedColor": "#CD5B45",

    "list": [

      {

        "pagePath": "pages/index/index",

        "text": "首页",

        "iconPath": "static/tabbar/ic_menu_choice_nor.png",

        "selectedIconPath": "static/tabbar/ic_menu_choice_pressed.png"

      },

      {

        "pagePath": "pages/home/home",

        "text": "我的",

        "iconPath": "static/tabbar/ic_menu_me_nor.png",

        "selectedIconPath": "static/tabbar/ic_menu_me_pressed.png"

      }

    ]

  }

}