# 配置
`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的注冊`,`頁面路由`,`數據更新`,`事件觸發` 。 可以幫助開發者快速定位一些常見的問題。
- 簡介
- 第一章 公眾號開發
- 使用微信JSSDK
- 接口權限配置
- 分享接口
- 隱藏按鈕項
- 微信支付
- 第二章 小程序開發
- 基礎知識
- 分包加載
- WXSS樣式表
- 配置
- app.json配置
- window
- tabBar
- page.json配置
- 邏輯層
- app.js
- 場景值
- page.js
- 初始化數據
- 生命周期函數
- 頁面相關事件處理函數
- 事件處理函數
- 頁面實例方法
- 路由
- 文件作用域
- 模塊化
- 視圖層
- 模板語法
- 列表渲染
- 條件渲染
- 模板
- 事件
- 引用
- WXS語法規范
- WXS數據類型
- WXS控制流程
- WXS基礎類庫
- 組件
- 視圖容器
- view
- scroll-view
- swiper
- movable-view
- cover-view
- 基礎組件
- icon
- text
- rich-text
- progress
- 表單組件
- button
- checkbox
- form
- input
- label
- picker
- picker-view
- radio
- slider
- switch
- textarea
- 導航組件
- navigator
- 媒體組件
- audio
- image
- video
- camera
- 地圖組件
- map
- 畫布組件
- canvas
- 開放能力
- web-view
- 自定義組件
- 組件模版和樣式
- Component
- 組件傳值
- 組件事件
- Behaviors
- 組件間關系
- 網絡請求
- wx.request
- 微信登錄
- 獲取 openid 和 unionid
- 獲取用戶信息
- 將 wx.request 封裝為 promise
- 上傳圖片接口封裝
- 數據存儲
- 存儲數據和讀取數據
- 獲取數據緩存信息
- 移除數據緩存
- 獲取用戶設置
- openSetting
- getSetting
- 第三章 小游戲開發
- 參考資料