常用其他全局配置
原创...大约 2 分钟
小程序根目录下的 app.json
文件用来对微信小程序进行其他全局配置。文件内容为一个 JSON 对象
属性 | 类型 | 必填 | 描述 |
---|---|---|---|
style | string | 否 | 指定使用升级后的 weui 样式 |
sitemapLocation | string | 是 | 指明 sitemap.json 的位置 |
networkTimeout | Object | 否 | 网络超时时间 |
debug | boolean | 否 | 是否开启 debug 模式,默认关闭 |
debugOptions | Object | 否 | 调试相关配置 |
permission | Object | 否 | 小程序接口权限相关设置 |
... | ... | ... | ... |
{
"entryPagePath": "pages/index/index",
"pages": [
"pages/news/news",
"pages/index/index",
"pages/logs/logs",
"pages/about/about"
],
"window": {
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "第一个小程序",
"backgroundColor": "#000000",
"backgroundTextStyle": "light",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
},
"tabBar": {
"color": "#999999",
"selectedColor": "#ff0000",
"backgroundColor": "#fff",
"borderStyle": "black",
"position": "bottom",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "./images/home.png",
"selectedIconPath": "./images/home_select.png"
},
{
"pagePath": "pages/news/news",
"text": "新闻",
"iconPath": "./images/news.png",
"selectedIconPath": "./images/news_select.png"
}
]
},
"style": "v2",
"sitemapLocation": "sitemap.json",
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true,
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"debugOptions": {
"enableFPSPanel": true
}
}
style
微信客户端 7.0 开始,UI 界面进行了大改版。小程序也进行了基础组件的样式升级。app.json 中配置 "style": "v2"
可表明启用新版的组件样式
sitemapLocation
指明 sitemap.json
的位置;默认为 'sitemap.json'
即在 app.json
同级目录下名字的 sitemap.json
文件
networkTimeout
各类网络请求的超时时间,单位均为毫秒
属性 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
request | number | 否 | 60000 | wx.request 的超时时间,单位:毫秒 |
connectSocket | number | 否 | 60000 | wx.connectSocket 的超时时间,单位:毫秒 |
uploadFile | number | 否 | 60000 | wx.uploadFile 的超时时间,单位:毫秒 |
downloadFile | number | 否 | 60000 | wx.downloadFile 的超时时间,单位:毫秒 |
debug
可以在开发者工具中开启 debug
模式,在开发者工具的控制台面板,调试信息以 info
的形式给出,其信息有 Page
的注册,页面路由,数据更新,事件触发等。可以帮助开发者快速定位一些常见的问题
debugOptions
小程序调试相关配置项
属性 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
enableFPSPanel | boolean | 否 | false | 是否开启 FPS 面板 |
FPS 面板
为了便于开发者调试渲染层的交互性能,小程序基础库提供了选项开启 FPS 面板,开发者可以实时查看渲染层帧率
开启方式:
"debugOptions": {
"enableFPSPanel": true
}
提示
必须在真机上才能看到
permission
小程序接口权限相关设置
例如:小程序定位设置,配置如下
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
}
Powered by Waline v2.15.7