全局配置
window节点
app.json中的window节点。
全局定义小程序所有页面的背景色、文字颜色等
window节点常用配置项
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| navigationBarTitleText | String | 字符串 | 导航栏标题文字内容 |
| navigationBarBackgroundColor | HexColor | #000000 | 导航栏背景颜色 |
| navigationBarTextStyle | String | White | 导航栏标题颜色,仅支持black/white |
| navigationBarTitleText | String | 字符串 | 导航栏标题文字内容 |
| backgroundColor | HexColor | #ffffff | 窗口的背景色 |
| backgroundTextStyle | String | dark | 下拉loading的样式,仅支持dark/light |
| enablePullDownRefresh | Boolean | false | 是否全局开启下拉刷新。在app.json中启用下拉刷新功能,会作用于每个小程序页面 |
| onReachBottomDistance | Number | 50 | 页面上拉触底事件触发时距页面底部距离,单位为px。建议使用默认值即可 |
tabBar
tabBar是移动端应用常见的页面效果,用于实现多页面的快速切换,也就是导航栏。分为
- 底部tabBar
- 顶部tabBar
注意
- tabBar中只能配置最少2个、最多5个tab标签
- 当渲染顶部tabBar时,不显示icon图标,只显示文本
tabBar的6个组成部分
| 组成部分 | 作用 |
|---|---|
| backgroundColor | tabBar的背景颜色 |
| borderStyle | tabBar上边框的颜色 |
| color | tab上文字的默认颜色(未选中时颜色) |
| selectedColor | tab上文字选中时的颜色 |
| iconPath | tab未选中时的图片路径(图标) |
| selectedIconPath | tab选中时的图片路径(图标) |
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 | 是 | 页面路径,页面必须在pages中预先预定 |
| text | String | 是 | tab上显示的文字 |
| iconPath | String | 否 | tab未选中时的图标路径;当position为top时,不显示icon |
| selectedIconPath | String | 否 | tab选中时的图标路径;当position为top时,不显示icon |
注意 tab项的对应页面需要在pages配置项属性值的多个页面前存放,否则点击tab页签时显示不出页面
页面配置
页面中的.json配置文件,对当前页面的窗口外观、页面效果等进行配置
注意 当全局配置与页面配置冲突时,根据就近原则,最终以页面配置为准
配置项和全局配置项相同