Global Configuration
The app.json file in the root directory of the mini program is used to configure the mini program globally. The content of the file is a JSON object.
Configuration Items
| Property | Type | Required | Description |
|---|---|---|---|
| entryPagePath | string | No | The default launch page of the mini program |
| pages | string[] | Yes | List of page paths |
| window | Object | No | Global default window presentation |
| tabBar | Object | No | Bottom tab bar presentation |
| networkTimeout | Object | No | Network timeout settings |
| debug | boolean | No | Whether to enable debug mode, default is false |
| subpackages | Object[] | No | Subpackage structure configuration |
| preloadRule | Object | No | Subpackage pre-download rules |
| workers | string | No | Directory for Worker code |
| requiredBackgroundModes | string[] | No | Capabilities required in the background, e.g., "audio" |
| plugins | Object | No | Plugins used |
| resizable | boolean | No | Whether PC mini program supports arbitrary window resizing |
| usingComponents | Object | No | Global custom component configuration |
| permission | Object | No | Mini program interface permission settings |
| sitemapLocation | string | Yes | Location of sitemap.json |
| style | string | No | Specify to use upgraded weui style |
| useExtendedLib | Object | No | Specify extended libraries to reference |
| entranceDeclare | Object | No | WeChat message open with mini program |
| darkmode | boolean | No | Whether mini program supports DarkMode |
| themeLocation | string | No | Location of theme.json |
| lazyCodeLoading | string | No | Configure custom component code on-demand injection |
| singlePage | Object | No | Single page mode configuration |
entryPagePath
Specifies the default launch path (homepage) of the mini program. Common scenarios include launching from the chat list dropdown or the mini program list. If not filled, it defaults to the first item in the pages list. Page path parameters are not supported.
pages
Used to specify which pages the mini program consists of. Each item corresponds to the path (including filename) of a page. The filename does not need a suffix; the framework will automatically look for the corresponding .json, .js, .wxml, and .wxss files.
When entryPagePath is not specified, the first item in the array represents the initial page (homepage) of the mini program.
Example:
{
"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 | Description |
|---|---|---|---|
| navigationBarBackgroundColor | HexColor | #000000 | Navigation bar background color |
| navigationBarTextStyle | string | white | Navigation bar title and status bar color, supports black / white |
| navigationBarTitleText | string | Navigation bar title text | |
| navigationStyle | string | default | Navigation bar style, supports default / custom |
| backgroundColor | HexColor | #ffffff | Window background color |
| backgroundTextStyle | string | dark | Pull-down loading style, supports dark / light |
| backgroundColorTop | string | #ffffff | Top window background color (iOS only) |
| backgroundColorBottom | string | #ffffff | Bottom window background color (iOS only) |
| enablePullDownRefresh | boolean | false | Whether to enable global pull-down refresh |
| onReachBottomDistance | number | 50 | Distance from bottom when reach bottom event triggers, in px |
| pageOrientation | string | portrait | Screen orientation, supports auto / portrait / landscape |
tabBar
If the mini program is a multi-tab application (tabs at the bottom or top of the client window), you can use the tabBar configuration item to specify the presentation of the tab bar and the paths of the pages corresponding to the tabs.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| color | HexColor | Yes | Text color on tab | |
| selectedColor | HexColor | Yes | Text color when tab is selected | |
| backgroundColor | HexColor | Yes | Background color of tab | |
| borderStyle | string | No | black | Border color of tabbar, supports black / white |
| list | Array | Yes | List of tabs, see list property description, min 2, max 5 tabs | |
| position | string | No | bottom | Position of tabBar, supports bottom / top |
| custom | boolean | No | false | Custom tabBar |
list
| Property | Type | Required | Description |
|---|---|---|---|
| pagePath | string | Yes | Page path, must be defined in pages |
| text | string | Yes | Button text on tab |
| iconPath | string | No | Image path, icon size limit 40kb, suggested size 81px * 81px |
| selectedIconPath | string | No | Image path when selected |
networkTimeout
Timeout for various network requests, in milliseconds.
| Property | Type | Default | Description |
|---|---|---|---|
| request | number | 60000 | wx.request timeout |
| connectSocket | number | 60000 | wx.connectSocket timeout |
| uploadFile | number | 60000 | wx.uploadFile timeout |
| downloadFile | number | 60000 | wx.downloadFile timeout |
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, including Page registration, page routing, data updates, event triggering, etc. This helps developers quickly locate common problems.
usingComponents
Custom components declared here are treated as global custom components and can be used directly in pages or custom components within the mini program without further declaration.
{
"usingComponents": {
"my-component": "/components/my-component/my-component"
}
}