We use the app.json file to globally configure the WeChat applet, determine the path of the page file, window performance, set the network timeout, set multiple tabs, etc.
The following is a simple configuration app.json that contains all configuration options
{ "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 }
The configuration properties are:
We explained the page configuration of the APP , window configuration, tabBar configuration, network configuration and other information
pages
Accepts an array, each item is a string, to specify the applet What pages are composed of. Each item represents the [path + file name] information of the corresponding page, and the first item in the array represents the initial page of the mini program. Adding/reducing pages in the mini program requires modifying the pages array.
There is no need to write a file suffix in the file name, because the framework will automatically look for the four files in the path .json, .js, .wxml, and .wxss for integration.
For example, the development directory is:
pages/
pages/index/index.wxml
pages/index/index.js
pages/index/index.wxss
pages/logs/logs.wxml
pages/logs/logs.js
app.js
app .json
app.wxss
then, we need to write
{ "pages":[ "pages/index/index" "pages/logs/logs" ] }
window
in app.json to set the status bar of the mini program, Navigation bar, title, window background color. The relevant attributes are as follows:
{ "window":{ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "微信接口功能演示", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light" } }
The compiled display result is as shown below:
tabBar
If our applet is a multi-tab application (there is a tab bar at the bottom or top of the client window to switch pages), then we can specify the performance of the tab bar through the tabBar configuration item, and the corresponding page displayed when the tab is switched.
Tip: The page reached through page jump (wx.navigateTo) or page redirection (wx.redirectTo), even if it is a page defined in the tabBar configuration, will not display the bottom tab bar. .
tabBar is an array, and only a minimum of 2 and a maximum of 5 tabs can be configured. The tabs are sorted in the order of the array.
#For more articles related to the configuration of WeChat mini programs, please pay attention to the PHP Chinese website!