一、小程序窗口的组成部分
二、全局配置
2.1. window 节点常用的配置项
2.2. 举例说明
2.2.1. 设置导航栏的标题
navigationBarTitleText
2.2.2. 设置导航栏的背景色
navigationBarBackgroundColor
2.2.3. 设置导航栏的标题颜色
navigationBarTextStyle
2.2.4. 全局开启下拉刷新功能
enablePullDownRefresh
2.2.5. 设置下拉刷新时窗口的背景色
backgroundColor
2.2.6. 设置下拉刷新时 loading 的样式
backgroundTextStyle
2.2.7. 设置上拉触底的距离
onReachBottomDistance
2.3. tabBar
2.3.1. tabBar的6个组成部分
2.3.2. tabBar节点的配置项
2.3.3. 每个tab 项的配置选项
2.3.4. 示例
"pages": [
"pages/pickFriend/pickFriend",
"pages/leftNote/leftNote",
"pages/pickedNote/pickedNote",
"pages/index/index"
],
//...省略
"tabBar": {
"selectedColor": "#0052D9",
"color": "#666666",
"borderStyle": "white",
"list": [{
"pagePath": "pages/pickFriend/pickFriend",
"text": "抽个对象",
"iconPath": "/images/tabbar/tab1-inactive.png",
"selectedIconPath": "/images/tabbar/tab1-active.png"
}, {
"pagePath": "pages/leftNote/leftNote",
"text": "留的纸条",
"iconPath": "/images/tabbar/tab2-inactive.png",
"selectedIconPath": "/images/tabbar/tab2-active.png"
}, {
"pagePath": "pages/pickedNote/pickedNote",
"text": "抽中纸条",
"iconPath": "/images/tabbar/tab3-inactive.png",
"selectedIconPath": "/images/tabbar/tab3-active.png"
}]
},
三、页面配置
3.1. 页面配置文件的作用
小程序中,每个页面都有自己的
.json
配置文件,用来对当前页面的窗口外观、页面效果等进行配置
3.2. 页面配置和全局配置的关系
3.3. 页面配置中常用的配置项
支持对单个页面进行配置,可以在页面对应的.json
文件来对本页面的表现进行配置,页面中配置项在当前页面会覆盖 app.json
中相同的配置项,但这里不需要额外指定 window 字段,文件内容为一个 JSON 对象,具有如下字段:
{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "微信接口功能演示",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}