1. 程式人生 > 實用技巧 >微信小程式全域性配置和頁面配置

微信小程式全域性配置和頁面配置

小程式根目錄下的 app.json 檔案用來對微信小程式進行全域性配置,決定頁面檔案的路徑、視窗表現、設定網路超時時間、設定多 tab 等。

{
  "pages": [
    "pages/index/index",
    "pages/logs/index"
  ],
  "window": {
    "navigationBarTitleText": "Demo"
  },
  "tabBar": {
    "list": [{
      "pagePath": "pages/index/index",
      "text": "首頁"
    }, {
      "pagePath": "pages/logs/index",
      "text": "日誌"
    }]
  },
  "networkTimeout": {
    "request": 10000,
    "downloadFile": 10000
  },
  "debug": true,
  "navigateToMiniProgramAppIdList": [
    "wxe5f52902cf4de896"
  ]
}



頁面配置

每一個小程式頁面也可以使用同名.json檔案來對本頁面的視窗表現進行配置,頁面中配置項會覆蓋app.jsonwindow中相同的配置項。

{
  "navigationBarBackgroundColor": "#ffffff",
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "www.dglantun.com",
  "backgroundColor": "#eeeeee",
  "backgroundTextS