May 18, 2021 WeChat Mini Program Development Document
The app.json file under the root of the small program is used to configure the WeChat program globally. The contents of the file are a JSON object with the following properties:
Property | Type | Required | Describe | The lowest version |
---|---|---|---|---|
entryPagePath | string | Whether | The small program starts the home page by default | |
pages | string[] | Is | The list of page paths | |
window | Object | Whether | The default window performance for the global | |
tabBar | Object | Whether |
The performance
tab
bar
|
|
networkTimeout | Object | Whether | Network timeout | |
debug | boolean | Whether | Whether debug mode is turned on or off by default | |
functionalPages | boolean | Whether | Whether to enable plug-in function pages, closed by default | 2.1.0 |
subpackages | Object[] | Whether | Subcontract structure configuration | 1.7.3 |
workers | string | Whether |
Worker
where the Worker code is placed
|
1.9.90 |
requiredBackgroundModes | string[] | Whether | Capabilities that need to be used in the background, such as "music playback" | |
plugins | Object | Whether | The plug-in to which it is used | 1.9.6 |
preloadRule | Object | Whether | Subcontract pre-download rules | 2.3.0 |
resizable | boolean | Whether | Whether the PC applet allows the user to change the window size arbitrarily, including maximizing the window, and whether the iPad applet supports screen rotation. Off by default | 2.3.0 |
usingComponents | Object | Whether | Global custom component configuration | Developer Tool 1.02.1810190 |
permission | Object | Whether | The settings related to the interface permissions of the small program | WeChat Client 7.0.0 |
sitemapLocation | string | Is | Indicates the location of sitemap.json | |
style | string | Whether | Specify to use the upgraded weui style | 2.8.0 |
useExtendedLib | Object | no | Specifies the extension library that needs to be referenced | 2.2.1 |
entranceDeclare | Object | no | WeChat messages open with a small program | WeChat client 7.0.9 |
darkmode | boolean | no | Small procedure supports DarkMode | 2.11.0 |
themeLocation | string | no | Indicates the location.json position, Darkmode is RUE as required | Developer Tools 1.03.2004271 |
lazyCodeLoading | string | no | Configuring custom component code on demand | 2.11.1 |
singlePage | Object | no | Single page mode related configuration | 2.12.0 |
Specify the default startup path of the applet (Home), the common scenario is started from the WeChat chat list page, the small program list starts, etc.If you don't fill, you will default to the first item of the Pages list.Do not support the page path parameters.
{
"entryPagePath": "pages/index/index"
}
Used to specify which pages the program consists of, each corresponding to the path (with file name) information for a page. The file name does not need to write a file suffix, and the framework automatically looks for four files for the corresponding location, .json, .js, .wxml, and .wxss.
When entryPagePath is not specified, the first item of the array represents the initial page (home page) of the small program.
New/reduced pages in the small program require modifications to the pages array.
If 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'll need to write in app.json
{
"pages": ["pages/index/index", "pages/logs/logs"]
}
Used to set the status bar, navigation bar, title, window background color of a small program.
Property | Type | The default | Describe | The lowest version |
---|---|---|---|---|
navigationBarBackgroundColor | HexColor | #000000 |
The background color of the navigation bar,
#000000
|
|
navigationBarTextStyle | string | white |
Navigation bar title color, only
black
/
white
|
|
navigationBarTitleText | string | The text content of the navigation bar title | ||
navigationStyle | string | default |
Navigation bar style, only the following values are supported:
default
default style
custom
navigation bar, only the upper right corner capsule button.
See Note 2.
|
WeChat Client 6.6.0 |
backgroundColor | HexColor | #ffffff | The background color of the window | |
backgroundTextStyle | string | dark |
The style of the pull-down loading only
dark
light
|
|
backgroundColorTop | string | #ffffff | Background color of the top window, iOS only | WeChat Client 6.5.16 |
backgroundColorBottom | string | #ffffff | Background color of the bottom window, iOS only | WeChat Client 6.5.16 |
enablePullDownRefresh | boolean | false |
Whether to turn on global pull-down refresh.
See Page.onPullDownRefresh |
|
onReachBottomDistance | number | 50 |
The distance from the bottom of the page when the bottom-of-the-page event is triggered, in px.
See Page.onReachBottom for details |
|
pageOrientation | string | portrait |
Screen rotation settings to
auto
portrait
landscape
See the response for changes in the display area |
2.4.0 (auto) / 2.5.0 (landscape) |
Such as:
{
"window": {
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "微信接口功能演示",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}
}
If the widget is a multi-tab app (there is a tab bar at the bottom or top of the client window to switch pages), you can specify the performance of the tab bar through the tabBar configuration item, as well as the corresponding page that appears when tab switches.
Property | Type | Required | The default | Describe | The lowest version |
---|---|---|---|---|---|
color | HexColor | Is | The default color of the text on tab supports only heteed colors | ||
selectedColor | HexColor | Is | The color when the text on tab is selected, and only hetechem colors are supported | ||
backgroundColor | HexColor | Is | tab background color, only hete sixteen colors are supported | ||
borderStyle | string | Whether | black |
The color of the border on tabbar, only
black
/white is
white
|
|
list | Array | Is |
A list of tabs, as
list
the list property description, with a minimum of 2 and a maximum of 5 tabs
|
||
position | string | Whether | bottom |
TabBar location, support only
bottom
/
top
|
|
custom | boolean | Whether | false | Custom tabBar, see details | 2.5.0 |
Where list accepts an array, only a minimum of 2 and a maximum of 5 tabs can be configured. tab sorted in the order of arrays, each item is an object with the following property values:
Property | Type | Required | Description |
---|---|---|---|
pagePath | string | Is | Page path, which must be defined first in pages |
text | string | Is | tab on the button text |
iconPath | string | Whether |
Picture path, icon size limit of 40kb, recommended size of 81px x 81px, does not support network pictures.
Icon
position
not
top
when position is top.
|
selectedIconPath | string | Whether |
When the picture path is selected, the icon size limit is 40kb, the recommended size is 81px x 81px, and network pictures are not supported.
Icon
position
not
top
when position is top.
|
Timeouts for all types of network requests in milliseconds.
Property | Type | Required | The default | Description |
---|---|---|---|---|
request | number | Whether | 60000 | The time-out time of wx.request, in milliseconds. |
connectSocket | number | Whether | 60000 | Time-out time for wx.connectSocket, in milliseconds. |
uploadFile | number | Whether | 60000 | wx.uploadFile time-out in milliseconds. |
downloadFile | number | Whether | 60000 | wx.downloadFile time-out in milliseconds. |
Debug mode can be turned on in the developer tool, in the developer tool's console panel, debug information is given in the form of info, its information includes Page registration, page routing, data updates, event triggering, etc. Helps developers quickly locate common problems.
Base library 2.1.0 starts to support, and low versions need to be compatible.
The plug-in owner gadget needs to set this item to enable the plug-in feature page.
WeChat client 6.6.0, base library 1.7.3 and above version support
When subcontract loading is enabled, the project subcontract structure is declared.
Writing subPackages is also supported.
Base Library 1.9.90 starts to support, and low versions need to be compatible.
When you use Worker for multithreaded tasks, set up the directory where the Worker code is placed
WeChat Client 6.7.2 and above are supported
Affirms the ability to run in the background, in the type of array. The following items are currently supported:
Such as:
{
"pages": ["pages/index/index"],
"requiredBackgroundModes": ["audio", "location"]
}
Note: It is stated here that the interface running in the background can take effect directly on the development and experience versions, and the official version also needs to be approved.
Base library 1.9.6 starts to be supported, and low versions need to be compatible.
Declares the plug-in that the small program needs to use.
Base library 2.3.0 starts to support, and low versions need to be compatible.
Declare the rules for subcontracting pre-downloads.
Base library 2.3.0 starts to support, and low versions need to be compatible.
Small programs running on iPad can be set to support screen rotation.
A small program running on a PC that allows users to drag the window size at any scale or maximize the window in the small program menu
Developer Tools 1.02.1810190 and above are supported
Custom components declared here are considered global custom components that can be used directly within a page or custom component within a small program without any further declaration.
WeChat client 7.0.0 and above
The settings related to the interface permissions of the small program. The field type is Object and the structure is:
Property | Type | Required | The default | Describe |
---|---|---|---|---|
scope.userLocation | PermissionObject | Whether | Location-related permission claims |
PermissionObject structure
Property | Type | Required | The default | Description |
---|---|---|---|---|
desc | string | Is | Description of the interface purpose shown when the small program gets permissions. Up to 30 characters |
Such as:
{
"pages": ["pages/index/index"],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示" // 高速公路行驶持续后台定位
}
}
}
Indicates the location of sitemap.json; the default is 'sitemap.json', which is the sitemap.json file with the name in the app.json peer directory
{
"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,
}
Base library 2.8.0 starts to be supported, and low versions need to be compatible.
WeChat client 7.0 began with a major revision of the UI interface. T he small program also performed a style upgrade of the underlying components. Configure "style": "v2" in app.json to indicate that the new version of the component style is enabled.
The components involved in this change are button icon radio checkbox switchr. You can go to the small program sample for an experience.
Base Library 2.2.1 starts to support, and low versions need to be compatible.
The latest nightly developer tools are supported, while the base library is supported from npm-supported versions (2.2.1).
Specify the extension library that needs to be referenced. The following items are currently supported:
When specified, it is equivalent to introducing the latest version of the npm package associated with the extension library, without taking up the package volume of the small program. R eferences in subcontracts are not currently supported. The usage is as follows:
{
"useExtendedLib": {
"kbone": true,
"weui": true
}
}
WeChat client 7.0.9 and above versions are supported, iOS is not supported at this time
Chat location messages are opened with a ride-type program, for details.
"entranceDeclare": {
"locationMessage": {
"path": "pages/index/index",
"query": "foo=bar"
}
}
Developer Tools 1.03.2004271 and above are supported, and the base library 2.11.0 and above are supported
DarkMode is officially supported by WeChat iOS Client 7.0.12, Android Client 7.0.13, and by configuring "darkmode": true means that the current applet is suitable for DarkMode, all underlying components are displayed in different default styles depending on the system theme, and navigation bar and bar automatically switch tabs according to the developer's configuration.
Once configured, follow the DarkMode fit guidelines to complete the fitting work outside the base style.
{
"darkmode": true
}
Customize the path of theme.json, and when "darkmode":true is configured, the current profile is required.
{
"themeLocation": "/path/to/theme.json"
}
The base library 2.11.1 and above are supported, and below 2.11.1 are compatible but not optimized
Typically, code for all pages and custom components is injected during the start of a small program, and custom components and pages that are not used by the current page are not actually used after injection.
Starting with the underlying library version 2.11.1, small programs support selective injection of the necessary code to reduce the startup time and runtime memory of small programs.
{
"lazyCodeLoading": "requiredComponents"
}
When this is configured, the small program injects only the custom components and page code required for the current page, and the custom components that are not necessarily used on the page are not loaded and initialized.
Note: When this configuration is added, unused code files will not be executed.
The basic library 2.11.3 and above are supported and now open into single-page mode when shared with Beta
One-page mode-related configuration
Property | Type | Required | The default | Describe |
---|---|---|---|---|
navigationBarFit | String | Whether | Auto-adjust by default, float if the original page is a custom navigation bar, otherwise it is squeezed | The intersecting state of the navigation bar and the page, with a value of float, states that the navigation bar floats on the page and intersects the page, and a value of squeezed shows that the page is squeezed by the navigation bar and does not intersect the page |