微信全局配置文件app.json

app.json常用配置项:

  • pages:记录当前小程序所有页面的存放路径
  • windows:全局设置小程序窗口的外观
  • tabBar:设置小程序底部的tabBar效果
  • style:是否启用新版的组件样式

app.json组成示意图:

小程序窗口的组成部分:
窗口组成部分

Windows配置项

属性名 类型 默认值 说明
navigationBarTitleText String 字符串 导航栏标题文字内容
navigationBarBackgroundColor HexColor #000000 导航栏背景颜色,如 #000000
navigationBarTextStyle String white 导航栏标题颜色,仅支持black/white
backgroundColor HexColor #ffffff 窗口的背景色
backgroundTextStyle String dark 下拉 loading 的样式,仅支持dark/light
enablePullDownRefresh Boolean false 是否全局开启下拉刷新
onReachBottomDistance Number 50 页面上拉触底事件触发时距页面底部距离,单位为px

tabBar配置项

作用: 是移动端应用常见的页面效果,用于实现多页面的快速切换

  • tabBar分为底部tabBar顶部tabBar
  • 当设置为顶部tabBar时不显示icon(即按钮图标),只显示文本。
  • tabBar最少2个、最多5个tab页签。
    tabBar组成示意图及说明如下:

tabBar配置项如下

属性 类型 必填 默认值 描述
position String bottom tabBar的位置,仅支持bottom/top
borderStyle String black tabBar上边框的颜色,仅支持black/white
color HexColor   tab上文字的默认(未选中)颜色
selectedColor HexColor   tab上的文字选中时的颜色
backgroundColor HexColor   tabBar的背景色
list Array   tab页签的列表,最少2个、最多5个tab

每个tab项的配置选项如下

属性 类型 必填 描述
pagePath String tab 上显示的文字
text String 页面路径,页面必须在pages中预先定义
iconPath String 未选中时的图标路径;当postion 为top时,不显示icon
selectedIconPath String 选中时的图标路径;当postion为top时,不显示icon