主体文件
window属性
window属性对应的值是对象形式,其中包括了小程序页面顶端导航栏的背景颜色、标题文字内容以及文字颜色等属性。
属性 | 类型 | 默认值 | 描述 |
---|---|---|---|
navigationBar BackgroundColor | HexColor | #000000 | 导航栏的背景颜色,默认值表示黑色,也可以简写为#000 |
navigationBarTextStyle | String | white | 导航栏的背景颜色,默认值表示白色,该属性值只能是white活black |
navigationBarTitleText | String | 导航栏标题文字内容,默认是无文字内容 | |
navigationStyle | String | defult | 导航栏样式,只支持default或custom,其中custom用于自定义导航栏的内容,只保留右上角的小图标(微信版本6.6.0以上支持此功能) |
backgroundColor | HexColor | #ffffff | 窗口的背景颜色,默认值表示白色,也可以简写为#fff |
backgroundTextStyle | String | dark | 下拉加载的样式,该属性值只能是dark或light |
backgroundColorTop | String | #ffffff | 顶部窗口的背景颜色,只有iOS 有效(微信版本6.5.16以上支持此功能) |
backgroundColorBottom | String | #ffffff | 底部窗口的背景颜色,只有 iOS 有效(微信版本6.5.16以上支持此功能) |
enablePullDownRefresh | Boolean | false | 是否开启下拉刷新功能 |
onReachBottomDistance | Number | 50 | 页面上拉触底事件触发时距页面底部的距离,单位为像素(px) |
注意 :标记类型为 HexColor 的属性值只支持十六进制颜色表示方式
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "ff0", /*将导航栏背景颜色从白色改为红色(#ff0)*/
"navigationBarTitleText": "测试", /*将导航栏文字内容从“WeChat”改为“测试”*/
"navigationBarTextStyle":"white"/*将导航栏文字颜色从黑色改为白色*/
}
}
tabBar属性
如果小程序是一个多 tab 应用(客户端窗口的底部有 tab 栏可以切换页面),可以通过tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页面。
属性 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
color | HexColor | 是 | tab上的文字默认颜色 | |
selectedColor | HexColor | 是 | tab上的文字选中时的颜色 | |
backgroundColor | HexColor | 是 | tab的背景色 | |
borderStyle | String | 否 | black | tabBar上边框的颜色,仅支持black、white |
list | Array | 是 | tab的列表 | |
position | String | 否 | bottom | tabBar的位置,仅支持bottom、top |
注意: list接收一个数组,只能配置最少两个、最多5个 tab。
属性 | 类型 | 必填 | 描述 |
---|---|---|---|
pagePath | String | 是 | 页面路径,必须在 pages 中先定义 |
text | String | 是 | tab 上按钮的文字 |
iconPath | String | 否 | 图标路径,icon 大小限制为40KB,建议尺寸为81px*81px,不支持网络图片 |
selectedIconPath | String | 否 | 选中时的图标路径,icon大小限制为40KB,建议尺寸为81px*8lpx,不支持网络图片 |
注意: 当 position 属性值为 top 时, iconPath 和 selectedIconPath 属性无效,不显示图标。
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "首页"
},
{
"pagePath": "pages/demo/demo",
"text": "例题"
}
]
}
networkTimeout 属性
appson 中的 networkTimeout 属性可以用于设置各类网络请求的超时时间。
属性 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
request | Number | 否 | 60000 | wx.request0的超时时间,单位为毫秒 |
connectSocket | Number | 否 | 60000 | wx.connectSocket0的超时时间,单位为毫秒 |
uploadFile | Number | 否 | 60000 | wxuploadFile0的超时时间,单位为毫秒 |
downloadFile | Number | 否 | 60000 | wx.downloadFile0的超时时间,单位为毫秒 |
app.js
代码框架:
// app.js
App({
onLaunch: function () {},
globalData:{}
});
app.wxss
app.wxss文件用于在根目录下创建一个所有页面都可用的样式效果