# Global configuration

Mini Program root directory app.json The file is used for global configuration of the WeChat Mini Program. The file content is a JSON Object has the following properties

# Configuration item

attribute type Required describe Minimum version
entryPagePath string no Mini Program default start home page
pages string[] yes Page Path List
window Object no Global default window representation
tabBar Object no BOTTOM tab Column performance
networkTimeout Object no Network timeout
debug boolean no Whether or not to open debug Mode, off by default
functionalPages boolean no Enable plug-in feature pages, close by default 2.1.0
subpackages Object[] no Subcontract structure configuration 1.7.3
workers string no Worker Directory for code placement 1.9.90
requiredBackgroundModes string[] no Capabilities that need to be used in the background, such asMusic playing
plugins Object no Plug-ins used 1.9.6
preloadRule Object no Subcontract Predownload Rules 2.3.0
resizable boolean no PC Does the Mini Program support users to arbitrarily change the size of the window (including maximizing the window)?iPad Whether the Mini Program supports screen rotation. Default Shutdown 2.3.0
usingComponents Object no overall situationCustom component configuration Developer tools 1.02.1810190
permission Object no Small Program Interface Permissions Related Settings WeChat Client 7.0.0
sitemapLocation string yes Specify sitemap.json Location
style string no Specify to use upgraded weui styles 2.8.0
useExtendedLib Object no Specify extension libraries that need to be referenced 2.2.1
entranceDeclare Object no WeChat messages opened with a Mini Program WeChat client 7.0.9
darkmode boolean no Mini Program support DarkMode 2.11.0
themeLocation string no Specify theme.json And dark mode true is required Developer tools 1.03.2004271
lazyCodeLoading string no Configure Custom Component Code On Demand Injection 2.11.1
singlePage Object no Single-page mode correlation configuration 2.12.0

# entryPagePath

Specify the default start path (home page) of the Mini Program, common scenario is from the WeChat chat list page drop-down start, Mini Program list start. If not, the default is pages The first item in the list. Page path parameters are not supported.

{
  "entryPagePath": "pages/index/index"
}

# pages

That specifies which pages the Mini Program consists of, with each item corresponding to a page Path (including file name) Information. Filename does not need to write file suffix, framework will automatically find the corresponding location .json, .js, .wxml, .wxss Four files for processing.

Not specified entryPagePath The first item in the array represents the initial page (home page) of the Mini Program.

Mini Program Added/Reduce pages, all need to be on pages Array to modify.

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 need to app.json Middle write

{
  "pages": ["pages/index/index", "pages/logs/logs"]
}

# window

Used to set Mini Program status bar, navigation bar, title, window background color.

attribute type Default value describe Minimum version
navigationBarBackgroundColor HexColor #000000 Navigation bar background color, such as #000000
navigationBarTextStyle string white Navigation bar header color, support only black / white
navigationBarTitleText string Navigation Title Text Content
navigationStyle string default Navigation bar style supports only the following values
default Default Style
custom Customize the navigation bar, leaving only the capsule on in the upper right corner. See note 2。
iOS/Android WeChat Client 6.6.0,Windows The client is not supported.
backgroundColor HexColor #ffffff The background color of the window
backgroundTextStyle string dark Pull down loading Style, only supports dark / light
backgroundColorTop string #ffffff The background color of the top window, only iOS Support WeChat Client 6.5.16
backgroundColorBottom string #ffffff The background color of the bottom window, only iOS Support WeChat Client 6.5.16
enablePullDownRefresh boolean false Whether to enable global drop-down refresh.
See for details Page.onPullDownRefresh
onReachBottomDistance number 50 The distance from the bottom of the page when the event is triggered, in px。
See for details Page.onReachBottom
pageOrientation string portrait Screen rotation settings, support car / portrait / landscape
See for details Response to display area changes
2.4.0 (car) / 2.5.0 (landscape)
  • notes 1: Hex Color (hex color value), as in "#ff00ff"
  • notes 2: AboutnavigationStyle
    • iOS/Android client 7.0.0 The following version,navigationStyle Only in app.json In effect.
    • iOS/Android client 6.7.2 Version starts,navigationStyle: custom Yes web-view Invalid component
    • open custom After the lower version of the client needs to do a good job of compatibility. Developer Tools Base Library Version Cut to 1.7.0 (does not represent the lowest version, only for debugging purposes) can easily cut to the old vision
    • Windows client 3.0 And above versions, in order to provide users with more consistent desktop software experience, unified the Mini Program window navigation bar,navigationStyle: custom No longer valid

Such as:

{
  "window": {
    "navigationBarBackgroundColor": "#ffffff",
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "WeChat interface function demonstration,"
    "backgroundColor": "#eeeeee",
    "backgroundTextStyle": "light"
  }
}

# tabBar

If the Mini Program is more than one tab Application (the bottom or top of the client window has tab Column to switch pages), you can click through the tabBar Configuration item designation tab Column performance, and tab The corresponding page to display when toggling.

attribute type Required Default value describe Minimum version
color HexColor yes tab Default color for text on, only hexadecimal color is supported
selectedColor HexColor yes tab Supports hexadecimal colors only
backgroundColor HexColor yes tab Supports only hexadecimal colors
borderStyle string no black Tabs The color of the top border, Support only black / white
list Array yes tab For a list of list Property explaination, minimum 2 Most 5 individual tab
position string no bottom tabBar Only supports the location of bottom / top
custom boolean no false custom Tab Bar, see you[details](<(ability/custom tabs)>) 2.5.0

among list Take an array,Only minimal configuration 2 Most 5 individual tab。 tab Sorted in the order of the array, each item is an object with the following property values

attribute type Required Introductions
pagePath string yes Page path, must be in the pages First definition
text string yes tab Up on text
iconPath string no Picture path, icon Size limit is 40kb, recommended size 81px * 81px, does not support web pictures.
when position for top Does not display when icon。
selectedIconPath string no Selected picture path, icon Size limit is 40kb, recommended size 81px * 81px, does not support web pictures.
when position for top Does not display when icon。

# networkTimeout

The timeout, in milliseconds, for each type of network request.

attribute type Required Default value Introductions
request number no 60000 wx.request In milliseconds.
connectSocket number no 60000 wx.connectSocket In milliseconds.
uploadFile number no 60000 wx.uploadFile In milliseconds.
downloadFile number no 60000 wx.downloadFile In milliseconds.

# debug

Can be turned on in the developer tools debug Mode, in the developer tools console panel, debugging information to info Is given in the form of Page Registration, page routing, data update, event triggering, etc. Can help developers quickly locate some common problems.

# functionalPages

Start from base library version 2.1.0. Please remaining backward compatible.

The plug-in owner Mini Program needs to set this item to enablePlugin function page

# subpackages

WeChat Client 6.6.0 Base library 1.7.3 And above version support

EnableSubcontract loading, declare the project sub-packageing structure.

Written subPackages Also support.

# workers

Start from base library version 1.9.90. Please remaining backward compatible.

Use Worker When working with multithreaded tasks, setting the Worker Directory for code placement

# requiredBackgroundModes

WeChat Client 6.7.2 And above version support

Declare the ability to run in the background, type array. The following projects are currently supported:

  • audio: Background Music Play
  • location: Background positioning

Such as:

{
  "pages": ["pages/index/index"],
  "requiredBackgroundModes": ["audio", "location"]
}

Note: Here declared the background running interface, the development version and experience version can be directly effective, the official version also needs to pass the audit.

# plugins

Start from base library version 1.9.6. Please remaining backward compatible.

Declare that the Mini Program needs to useplug-in

# preloadRule

Start from base library version 2.3.0. Please remaining backward compatible.

statementSubcontract pre-download.

# resizable

Start from base library version 2.3.0. Please remaining backward compatible.

in iPad Running on the Mini Program can set supportScreen Rotation

in PC Run on the Mini Program, the user can drag the window size according to any proportion, you can also maximize the window in the Mini Program menu

# usingComponents

Developer tools 1.02.1810190 And above version support

The custom components declared here are treated as global custom components and can be used directly in pages within the Mini Program or in custom components without further declaration.

# permission

WeChat Client 7.0.0 And above version support

Mini ProgramInterface Permissions Related settings. Field type is Object, structured as:

attribute type Required Default value describe
scope.userLocation PermissionObject no Location-dependent permission statement

PermissionObject structure

attribute type Required Default value Introductions
desc string yes A explaination of the purpose of the interface displayed when the Mini Program acquires permissions. Longest 30 Character

Such as:

{
  "pages": ["pages/index/index"],
  "permission": {
    "scope.userLocation": {
      "desc": "Your location information will be used to display the effects of the Mini Program location interface." // Continuous Background Positioning for Freeway Driving
    }
  }
}

# sitemapLocation

Specify sitemap.json LocationDefault is sitemap.json That is, app.json Of the name in the sibling directory sitemap.json file

# Configuration sample

{
  "pages": ["pages/index/index", "pages/logs/index"],
  "window": {
    "navigationBarTitleText": "Demo"
  },
  "tabBar": {
    "list": [
      {
        "pagePath": "pages/index/index",
        "text": "Home Page"
      },
      {
        "pagePath": "pages/logs/logs",
        "text": "Log."
      }
    ]
  },
  "networkTimeout": {
    "request": 10000,
    "downloadFile": 10000
  },
  "debug": true,
}

# style

Start from base library version 2.8.0. Please remaining backward compatible.

WeChat Client 7.0 Start, UI The interface has undergone a major overhaul. The Mini Program also has a style upgrade for the underlying component. apagejson Configuration in "style": "v2"Can indicate that a new version of the component style is enabled.

The components involved in this change are button icon radio checkbox switch sliderYou can go to the Mini Programs sample to experience.

# useExtendedLib

Start from base library version 2.2.1. Please remaining backward compatible.

Latest nightly Version of the developer tool to start support, while the base library from support npm Version (2.2.1)

Specifies the extension library to be referenced. The following projects are currently supported:

When specified, is equivalent to introducing the latest version of the corresponding extension library npm Package, but also does not occupy the Mini Programs package volume. The rc tool version supports sub-packageing references. Usage is as follows:

{
  "useExtendedLib": {
    "kbone": true,
    "weui": true
  }
}

# entranceDeclare

WeChat Client 7.0.9 And above version support, iOS Temporary support

Chat location message with a taxi class Mini Program to open,Details Reference

"entranceDeclare": {
    "locationMessage": {
        "path": "pages/index/index",
        "query": "foo=bar"
    }
}

# darkmode

Developer tools 1.03.2004271 And above version support, base library 2.11.0 And above version support

WeChat iOS client 7.0.12 Version, Android client 7.0.13 Version Official Support Dark Mode can be configured by"darkmode": trueIndicates that the current Mini Program is adaptable DarkMode, all basic components will display different default styles according to the system theme, navigation bar and tab bar It also switches automatically depending on the developer's configuration.

Once configured, follow the[DarkMode Adaptation guidelines](../../framework/ability/Darkmode. md does the adaptation work itself beyond the base style.

{
  "darkmode": true
}

# themeLocation

custom theme.json Path, when configured'darkmode': trueThe current configuration file is required.

{
  "themeLocation": "/path/to/theme.json"
}

# lazyCodeLoading

Currently only supported values requiredComponentsRepresents the opening of the Mini ProgramOn-demand injection feature.

{
  "lazyCodeLoading": "requiredComponents"
}

# singlePage

Base library 2.11.3 And above, currentlyShare to your friends (Beta) Open later and enter single page mode

Single-page mode correlation configuration

attribute type Required Default value describe
navigationBarFit String no If the original page is a custom navigation bar; otherwise Float, otherwise squeezed The intersection of the navigation bar and the page, with a value of float Indicates that the navigation bar floats on the page and intersects the pageValue is squeezed Means that the page is squeezed by the navigation bar and does not intersect with the page