The app.json file in the root directory of the mini program is used to configure the WeChat mini program globally. The file content is a JSON object with the following properties: Configuration items property | type | Required | describe | Minimum version |
---|
pages | string[] | yes | Page path list | | window | Object | no | Global default window behavior | | tabBar | Object | no | Performance of the bottom tab bar | | networkTimeout | Object | no | Network timeout | | debug | boolean | no | Whether to enable debug mode, disabled by default | | functionalPages | boolean | no | Whether to enable the plugin function page, closed by default | 2.1.0 | subpackages | Object[] | no | Subcontract structure configuration | 1.7.3 | workers | string | no | Directory where Worker code is placed | 1.9.90 | requiredBackgroundModes | string[] | no | Capabilities that need to be used in the background, such as "music playback" | | plugins | Object | no | Plugins used | 1.9.6 | preloadRule | Object | no | Sub-package pre-download rules | 2.3.0 | resizable | boolean | no | Does the iPad applet support screen rotation? Disabled by default | 2.3.0 | navigateToMiniProgramAppIdList | string[] | no | List of mini-programs to be redirected, see wx.navigateToMiniProgram for details | 2.4.0 | usingComponents | Object | no | Global custom component configuration | Developer Tools 1.02.1810190 | permission | Object | no | Mini Program interface permission settings | WeChat Client 7.0.0 | sitemapLocation | string | yes | Specify the location of sitemap.json | | style | string | no | Specify the use of the upgraded weui style | 2.8.0 | useExtendedLib | Object | no | Specify the extension library to be referenced | 2.2.1 | entranceDeclare | Object | no | Open WeChat messages with mini-programs | WeChat Client 7.0.9 |
pages Used to specify which pages the mini program consists of. Each item corresponds to the path (including file name) information of a page. The file name does not need to have a file suffix, the framework will automatically look for the corresponding location's .json , .js , .wxml , and .wxss files for processing. The first item in the array represents the initial page (home page) of the mini program. To add/reduce pages in the applet, the pages array needs to be modified. For example, the development directory is: ├── app.js
├── app.json
├── app.wxss
├── pages
│ │── index
│ │ ├── index.wxml
│ │ ├── index.js
│ │ ├── index.json
│ │ └── index.wxss
│ └── logs
│ ├── logs.wxml
│ └── logs.js
└── utils You need to write in app.json {
"pages": ["pages/index/index", "pages/logs/logs"]} window Used to set the status bar, navigation bar, title, and window background color of the mini program. property | type | default value | describe | Minimum version |
---|
navigationBarBackgroundColor | HexColor | #000000 | Navigation bar background color, such as #000000 | | navigationBarTextStyle | string | white | Navigation bar title color, only supports black / white | | navigationBarTitleText | string | | Navigation bar title text content | | navigationStyle | string | default | Navigation bar style, only supports the following values: default default style custom the navigation bar and only keep the capsule button in the upper right corner. See Note 2. | WeChat Client 6.6.0 | backgroundColor | HexColor | #ffffff | The background color of the window | | backgroundTextStyle | string | dark | The style of the drop-down loading screen, only supports dark / light | | backgroundColorTop | string | #ffffff | The background color of the top window, only supported by iOS | WeChat Client 6.5.16 | backgroundColorBottom | string | #ffffff | The background color of the bottom window, only supported by iOS | WeChat Client 6.5.16 | enablePullDownRefresh | boolean | false | Whether to enable global pull-down refresh. See Page.onPullDownRefresh for details. | | onReachBottomDistance | number | 50 | The distance from the bottom of the page when the pull-to-bottom event is triggered, in px. See Page.onReachBottom for details. | | pageOrientation | string | portrait | Screen rotation settings, support auto / portrait / landscape See Response Display Area Changes for details. | 2.4.0 (auto) / 2.5.0 (landscape) |
- Note 1: HexColor (hexadecimal color value), such as "#ff00ff"
- Note 2: About
navigationStyle - For client versions below 7.0.0,
navigationStyle is only effective in app.json . - Starting from client version 6.7.2,
navigationStyle: custom is invalid for web-view components - After turning on custom, lower version clients need to be compatible. The developer tool base library version is switched to 1.7.0 (not the minimum version, only for debugging) to facilitate switching to the old visual
like: {
"window": {
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "WeChat API Function Demonstration",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}} tabBar If the mini program is a multi-tab application (there is a tab bar at the bottom or top of the client window for switching pages), you can use the tabBar configuration item to specify the performance of the tab bar and the corresponding page displayed when switching tabs. property | type | Required | default value | describe | Minimum version |
---|
color | HexColor | yes | | The default color of the text on the tab. Only hexadecimal colors are supported. | | selectedColor | HexColor | yes | | The color of the text on the tab when it is selected. Only hexadecimal colors are supported. | | backgroundColor | HexColor | yes | | The background color of the tab, only hexadecimal colors are supported | | borderStyle | string | no | black | The color of the tabbar top border, only supports black / white | | list | Array | yes | | The list of tabs. For details, see list attribute description. The minimum number of tabs is 2 and the maximum number of tabs is 5. | | position | string | no | bottom | The position of tabBar, only supports bottom / top | | custom | boolean | no | false | Customize tabBar, see details | 2.5.0 |
The list accepts an array, and can only configure a minimum of 2 and a maximum of 5 tabs . The tabs are sorted in the order of the array, and each item is an object with the following property values: property | type | Required | illustrate |
---|
pagePath | string | yes | Page path, must be defined in pages first | text | string | yes | Button text on tab | iconPath | string | no | Image path, icon size limit is 40kb, recommended size is 81px * 81px, network images are not supported. When position is top , the icon is not displayed. | selectedIconPath | string | no | The image path when selected. The icon size limit is 40kb. The recommended size is 81px * 81px. Internet images are not supported. When position is top , the icon is not displayed. |
networkTimeout The timeout for various network requests, in milliseconds. property | type | Required | default value | illustrate |
---|
request | number | no | 60000 | wx.request timeout, unit: milliseconds. | connectSocket | number | no | 60000 | The timeout period of wx.connectSocket, in milliseconds. | uploadFile | number | no | 60000 | The timeout period of wx.uploadFile, in milliseconds. | downloadFile | number | no | 60000 | The timeout period of wx.downloadFile, in milliseconds. |
debug You can enable debug mode in the developer tools. In the console panel of the developer tools, debug information is given in the form of info , which includes Page registration, page routing, data update, event triggering, etc. It can help developers quickly locate some common problems. functionalPages Support is available starting from basic library 2.1.0, and compatibility with lower versions is required.
The plugin owner applet needs to set this to enable the plugin function page. subpackages WeChat client 6.6.0, basic library 1.7.3 and above versions support
Declare the project subpackage structure when subpackage loading is enabled. SubPackages are also supported.
workers Support is available starting from the basic library 1.9.90, and lower versions need to be compatible.
When using Worker to handle multi-threaded tasks, set the directory where Worker code is placed requiredBackgroundModes Supported by WeChat client 6.7.2 and above
Declare the need for background running capability, the type is array. The following projects are currently supported: -
audio : background music playback -
location : background location
like: {
"pages": ["pages/index/index"],
"requiredBackgroundModes": ["audio", "location"]} Note: The interface for background operation is stated here. It can take effect directly in the development version and trial version, and the official version still needs to pass the review. plugins Support is available starting from the basic library 1.9.6, and lower versions need to be compatible.
Declare the plug-ins that the applet needs to use. preloadRule Support is available starting from basic library 2.3.0, and compatibility with lower versions is required.
Declare the rules for sub-package pre-download. resizable Support is available starting from basic library 2.3.0, and compatibility with lower versions is required.
Applets running on iPad can be set to support screen rotation. navigateToMiniProgramAppIdList Support is available starting from basic library 2.4.0, and compatibility with lower versions is required.
When a mini program needs to use the wx.navigateToMiniProgram interface to jump to other mini programs, it is necessary to first declare the appId list of the mini programs that need to be jumped in the configuration file. A maximum of 10 items are allowed. usingComponents Developer Tools 1.02.1810190 and above support
The custom components declared here are considered global custom components and can be used directly in pages or custom components within the mini-program without further declaration. permission Supported by WeChat client 7.0.0 and above
Mini Program interface permission related settings. The field type is Object and the structure is: property | type | Required | default value | describe |
---|
scope.userLocation | PermissionObject | no | | Location-related permission statement |
PermissionObject Structure property | type | Required | default value | illustrate |
---|
desc | string | yes | | Description of the interface usage displayed when the Mini Program obtains permissions. Maximum length: 30 characters |
like: {
"pages": ["pages/index/index"],
"permission": {
"scope.userLocation": {
"desc": "Your location information will be used to display the effect of the mini program location interface" // Continuous background positioning while driving on the highway }
}} sitemapLocation Specifies the location of sitemap.json; defaults to 'sitemap.json', which means the file named sitemap.json in the same directory as app.json Configuration Example {
"pages": ["pages/index/index", "pages/logs/index"],
"window": {
"navigationBarTitleText": "Demo"
},
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "Home"
},
{
"pagePath": "pages/logs/logs",
"text": "Log"
}
]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true,
"navigateToMiniProgramAppIdList": ["wxe5f52902cf4de896"]} style Support is available starting from basic library 2.8.0, and compatibility with lower versions is required.
Starting from WeChat client 7.0, the UI interface has undergone a major revision. The mini program has also upgraded the style of its basic components. Configuring "style": "v2" in app.json indicates that the new version of the component style is enabled. The components affected by this change are button icon radio checkbox switch slider . You can go to the mini program example to experience it. useExtendedLib Support is available starting from basic library 2.2.1. Compatibility with lower versions is required.
The latest nightly version of the developer tools starts to support it, and the basic library starts from the version that supports npm (2.2.1)
Specify the extension library to be referenced. The following projects are currently supported: -
kbone : multi-terminal development framework -
weui : WeUI component library
After specifying, it is equivalent to introducing the latest version of the npm package related to the corresponding extension library, and it does not occupy the package size of the mini program. References in subpackages are not currently supported. Usage is as follows: {
"useExtendedLib": {
"kbone": true,
"weui": true
}} entranceDeclare Supported by WeChat client 7.0.9 and above, not supported on iOS yet
Chat location messages can be opened with taxi-hailing mini-programs, see details for details. "entranceDeclare": {
"locationMessage": {
"path": "pages/index/index",
"query": "foo=bar" }} |