WeChat applet configuration

高洛峰
Release: 2017-03-01 11:38:01
Original
1831 people have browsed it

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
}
Copy after login

The configuration properties are:

WeChat applet configuration

We explained the page configuration of the APP , window configuration, tabBar configuration, network configuration and other information

WeChat applet configuration

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"
  ]
}
Copy after login

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:

WeChat applet configuration

{
  "window":{
    "navigationBarBackgroundColor": "#ffffff",
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "微信接口功能演示",
    "backgroundColor": "#eeeeee",
    "backgroundTextStyle": "light"
  }
}
Copy after login

The compiled display result is as shown below:

WeChat applet configuration

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.

WeChat applet configuration

#For more articles related to the configuration of WeChat mini programs, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!