一个小程序应用程序会包括最基本的两种配置文件。一种是全局的app.json 和 页面自己的 page.json
注意:配置文件中不能出现注释!
5.1 全局配置app.json
app.json是当前小程序的全局配置,包括了小程序的所有页面路径、界面表现、网络超时时间、底部tab等。普通快速启动项目里边的app.json配置。
{
"pages": [
"pages/img/img",
"pages/index/index",
"pages/search/search",
"pages/user/user",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#0094ff",
"navigationBarTitleText": "测试",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": true,
"backgroundColor": "#ccc"
},
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "icon/_home.png",
"selectedIconPath": "icon/home.png"
},
{
"pagePath": "pages/img/img",
"text": "图片",
"iconPath": "icon/_img.png",
"selectedIconPath": "icon/img.png"
},
{
"pagePath": "pages/search/search",
"text": "搜索",
"iconPath": "icon/_search.png",
"selectedIconPath": "icon/search.png"
},
{
"pagePath": "pages/user/user",
"text": "我的",
"iconPath": "icon/_my.png",
"selectedIconPath": "icon/my.png"
}
],
"color": "#000",
"selectedColor": "#0094ff",
"position": "bottom"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
字段的含义
1. pages
字段⸺⽤于描述当前⼩程序所有⻚⾯路径,这是为了让微信客⼾端知道当前你的⼩程序
⻚⾯定义在哪个⽬录。
2. window
字段⸺定义⼩程序所有⻚⾯的顶部背景颜⾊,⽂字颜⾊定义等。
3. 完整的配置信息请参考 app.json配置
这⾥的 page.json 其实⽤来表⽰⻚⾯⽬录下的 page.json这类和⼩程序⻚⾯相关的配置。
开发者可以独⽴定义每个⻚⾯的⼀些属性,如顶部颜⾊、是否允许下拉刷新等等。
⻚⾯的配置只能设置 app.json 中部分 window 配置项的内容,⻚⾯中配置项会覆盖 app.json 的 window 中相同的配置项。
{
"usingComponents": {},
"navigationBarBackgroundColor": "#ccc",
"navigationBarTitleText": "首頁"
}
小程序根目录下的 sitemap.json 文件用于配置小程序及其页面是否允许被微信索引。