企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 配置 `app.json` 文件用来对微信小程序进行全局配置,决定页面文件的路径、窗口表现、设置网络超时时间、设置多 tab 等。 比如: ```json { "pages": [ "pages/index/index", "pages/logs/index" ], "window": { "navigationBarTitleText": "Demo" }, "tabBar": { "list": [{ "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/logs/logs", "text": "日志" }] }, "networkTimeout": { "request": 10000, "downloadFile": 10000 }, "debug": true } ``` ## app.json 配置项列表 | 属性 | 类型 | 必填 | 描述 | | ---------------------------------------- | ------------ | ---- | --------------- | | [pages](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html#pages) | String Array | 是 | 设置页面路径 | | [window](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html#window) | Object | 否 | 设置默认页面的窗口表现 | | [tabBar](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html#tabbar) | Object | 否 | 设置底部 tab 的表现 | | [networkTimeout](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html#networktimeout) | Object | 否 | 设置网络超时时间 | | [debug](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html#debug) | Boolean | 否 | 设置是否开启 debug 模式 | ### pages 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成。每一项代表对应页面的【路径+文件名】信息,数组的第一项代表小程序的初始页面。小程序中新增/减少页面,都需要对 pages 数组进行修改。 文件名不需要写文件后缀,因为框架会自动去寻找路径下 `.json`, `.js`, `.wxml`, `.wxss` 四个文件进行整合。 ### networkTimeout 可以设置各种网络请求的超时时间。 **属性说明:** | 属性 | 类型 | 必填 | 说明 | | ------------- | ------ | ---- | ---------------------------------------- | | request | Number | 否 | [wx.request](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html)的超时时间,单位毫秒,默认为:60000 | | connectSocket | Number | 否 | [wx.connectSocket](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-socket.html)的超时时间,单位毫秒,默认为:60000 | | uploadFile | Number | 否 | [wx.uploadFile](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-file.html#wxuploadfileobject)的超时时间,单位毫秒,默认为:60000 | | downloadFile | Number | 否 | [wx.downloadFile](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-file.html#wxdownloadfileobject)的超时时间,单位毫秒,默认为:60000 | 如: ```json { "networkTimeout": { "request": 10000, "connectSocket": 10000, "uploadFile": 60000, "downloadFile": 60000 } } ``` ### debug 可以在开发者工具中开启 debug 模式,在开发者工具的控制台面板,调试信息以 info 的形式给出,其信息有`Page的注册`,`页面路由`,`数据更新`,`事件触发` 。 可以帮助开发者快速定位一些常见的问题。