【app.json】配置說明,不斷更新中


app.json文件用來對微信小程序進行全局配置,決定頁面文件的路徑、窗口表現、設置網絡超時時間、設置多 tab 等。

 

注意:

1) json配置中鍵名、鍵值必須使用雙引號,不能使用單引號。

2) 以下配置中除了page字段是必需設置,其它項目為可選項。

 

置項說明:

  1 {
  2 
  3   /**
  4   * 【必需】 pages 鍵值是一列數組
  5   * 指定小程序由哪些頁面組成,每一項都對應一個頁面的 路徑+文件名 信息。文件名不需要寫文件后綴
  6   * 數組第一項代表小程序的首頁
  7   **/
  8   "pages": [
  9     "pages/index/index",
 10     "pages/logs/index"
 11   ],
 12 
 13   
 14   /**
 15   * window 用於設置小程序的狀態欄、導航條、標題、窗口背景色。
 16   **/
 17   "window": {
 18       
 19     /**
 20     * 以下是頁面頂部導航欄設置
 21     **/
 22     "navigationBarBackgroundColor" : "[Color]", // 導航欄背景顏色,默認值:#000000
 23     "navigationBarTextStyle" : "white|black", // 導航欄標題顏色,默認值white
 24     "navigationBarTitleText": "[String]" , // 導航欄標題文字內容
 25     "navigationStyle" : "default|custom", // 導航樣式,默認值default。 custom 自定義導航欄,只保留右上角膠囊按鈕
 26     
 27     /**
 28     * 以下是下拉刷新或上拉觸底設置
 29     **/
 30     "backgroundColor" : "[Color]", // 窗口的背景色
 31     "backgroundTextStyle" : "dark|light", // 下拉 loading 的樣式,默認值dark(暗)
 32     "backgroundColorTop" : "[Color]", // 頂部窗口的背景色,僅 iOS 支持
 33     "backgroundColorBottom" : "[Color]", // 底部窗口的背景色,僅 iOS 支持    
 34     "enablePullDownRefresh" : true|false, // 是否全局開啟下拉刷新,值 true | false
 35     "onReachBottomDistance" : [Number] // 頁面上拉觸底事件觸發時距頁面底部距離,單位為px,默認值 50
 36     
 37   },
 38   
 39 
 40   /**
 41   * tabBar 配置項指定 tab 欄的表現,以及 tab 切換時顯示的對應頁面。
 42   **/
 43   "tabBar": {
 44     
 45     "color" : "[Color]", // 【必需】 tab 上的文字默認顏色
 46     "selectedColor" : "[Color]", // 【必需】 tab 上的文字選中時的顏色
 47     "backgroundColor" : "[Color]", // 【必需】 tab 的背景色
 48     "borderStyle" : "black|white", // tabbar上邊框的顏色, 默認值:black
 49     "position" : "bottom|top", // tabBar的位置,僅支持 bottom / top
 50     
 51     /**
 52     * 【必需】 tab 的列表,最少2個、最多5個 tab
 53     **/
 54     "list": [
 55       {
 56         "pagePath": "[String]", // 【必需】 打開的頁面路徑,必須在 pages 中先定義
 57         "text": "[String]", // 【必需】 tab 上按鈕文字,比如首頁
 58         "iconPath" : "[String]", // 圖片路徑,icon 大小限制為40kb,建議尺寸為 81px * 81px,不支持網絡圖片。 當 postion 為 top 時,不顯示 icon。
 59         "selectedIconPath" : "[String]" // 選中時的圖片路徑,icon 大小限制為40kb,建議尺寸為 81px * 81px,不支持網絡圖片。當 postion 為 top 時,不顯示 icon。
 60       }, 
 61       {
 62         "pagePath": "[String]",
 63         "text": "[String]", 
 64         "iconPath" : "[String]", 
 65         "selectedIconPath" : "[String]" 
 66       }
 67       //設置每個列表...
 68     ]
 69   },
 70   
 71   
 72   /**
 73   * networkTimeout 各類網絡請求的超時時間,單位均為毫秒。
 74   **/
 75   "networkTimeout": {
 76     "request" : [Number],  // wx.request 的超時時間。默認值 60000
 77     "connectSocket" : [Number], // wx.connectSocket 的超時時間。默認值 60000 
 78     "uploadFile" : [Number], // wx.uploadFile 的超時時間。默認值 60000
 79     "downloadFile": [Number] // wx.downloadFile 的超時時間。默認值 60000
 80   },
 81   
 82   
 83   /**
 84   * debug 是否開啟調試模式,默認關閉(false)
 85   **/
 86   "debug": true|false, 
 87 
 88   "resizable": true|false, // 值true時使小程序支持 iPad 屏幕旋轉 
 89   /**
 90   * functionalPages 是否啟用插件功能頁,默認關閉(false)
 91   **/
 92   "functionalPages" : true|false,
 93   
 94 
 95   /**
 96   * usingComponents 定義全局可以使用的自定義組件(所有頁面可用)
 97   **/
 98   "usingComponents": {      
 99       "component-tag-name": "component-path", // 格式:組件標簽名稱 : 自定義組件路徑
100       // 可定義多個自定義組件
101    }
102   
103   /**
104   * subPackages
105   **/
106   
107   
108   /**
109   * workers
110   **/
111   
112   
113   /**
114   * requiredBackgroundModes
115   **/
116   
117   
118   /**
119   * plugins
120   **/
121   
122 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM