全局配置
小程序目录下的app.json文件是小程序的全局配置文件
pages 记录当前小程序所有页面的存放路径
window 全局设置小程序窗口的外观
tabBar 设置小程序底部的tabBar效果
style 是否启用新版的组件样式
window
小程序窗口的组成
navigationBar 头部导航栏
background 下拉刷新区域
主体区域 用来显示wxml中的布局
常用配置项
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
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 |
上拉触底是移动端专有名词,通过手指在屏幕上的上拉滑动操作,从而加载更多数据,默认为50px
tabBar
tabBar是移动端页面常见的页面效果,用于实现多页面的快速切换,通常分为底部tabBar和顶部tabBar
tabBar中只能配置最少2个,最多5个tab标签,当渲染顶部tabBar时,不显示icon,只显示文本
tabBar的配置项
属性 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
list | Array | 是 | tab页签的列表,最少2个,最多5个tab | |
position | String | 否 | bottom | tabBar的位置,仅支持bottom/top |
borderStyle | String | 否 | black | tabBar上边框的颜色,仅支持black/white |
color | HexColor | 否 | tab上文字的默认(未选中)颜色 | |
selectedColor | HexColor | 否 | tab上的文字选中时的颜色 | |
backgroundColor | HexColor | 否 | tabBar的背景色 |
每个tab项的配置项
属性 | 类型 | 必填 | 描述 |
---|---|---|---|
pagePath | String | 是 | 页面路径,页面必须在pages中预先定义 |
text | String | 是 | tab上显示的文字 |
iconPath | String | 否 | 未选中的图标路径;当position为top时,不显示icon |
selectedIconPath | String | 否 | 选中时的图标路径;当position为top时,不显示icon |
注:
list数组中的pagePath为pages中的路径
且需要tanBar切换的页面必须放在pages数组中的前面
页面配置
小程序中app.json中的window节点,可以在全局配置小程序中的每个页面的窗口表现
页面的.json配置文件可以实现单独的页面窗口表现
当页面配置与全局配置冲突时,根据就近原则,以页面配置为准
常用配置项
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
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 |