Micro-Letter Applet configuration file Details _javascript

Source: Internet
Author: User

The following is an example of a program framework that is automatically generated by the developer tool, and introduces the framework of a small program.

Select an empty project directory to create a small program project, as shown in the following figure:

After the creation is complete, we see the following directory structure:
directory Structure

The applet contains an app that describes the whole program and a page that describes the respective pages.

A small program body part consists of three files, which must be placed in the root directory of the project as follows:

file must be function
App.js Is Small program Logic
App.json Is Applet Public Settings
App.wxss Whether Small Program Common style sheet

Pages directory for the Small Program page, each page must establish a separate folder, such as the resulting small program has two pages, respectively, Pages/index, Pages/logs, a page composed of four files, respectively:

File Type must be function
Js Is Page logic
Wxml Is Page structure
Wxss Whether Page style Sheet
Json Whether Page configuration

Configuration

App.json file to the micro-mail program for the global configuration, determine the page file path, window performance, set the network timeout time, the setting of multiple tab.
The contents of the configuration file in the example are as follows:

{
 "pages": [
  "Pages/index/index",
  "Pages/logs/logs"
 ],
 "window": {
  " Backgroundtextstyle ":" Light ","
  Navigationbarbackgroundcolor ":" #fff ",
  " Navigationbartitletext ":" WeChat ",
  " Navigationbartextstyle ":" Black "
 }
}

App.json provides the following configuration items:

Property type must fill Description
Pages String Array Is Set page path
Window Object Whether Set the window performance for the default page
Tabbar Object Whether Set the bottom
Networktimeout Object Whether Set Network timeout time
Debug Boolean Whether Set whether to open

Accept an array, each of which is a string, to specify which pages the applet consists of. Each item represents the "Path + filename" information for the corresponding page, and the first item of the array represents the initial page of the applet. The new/reduced page in the applet requires modifications to the pages array.

Window

Used to set the status bar, navigation bar, title, and window background color of the applet.

Property type Default Value Description
Navigationbarbackgroundcolor Hexcolor 000000 Navigation bar background color, such as "#000000"
Navigationbartextstyle String White Navigation bar title color, support only Black/white
Navigationbartitletext String Navigation bar Title text content
BackgroundColor Hexcolor Ffffff Background color of Windows
Backgroundtextstyle String Dark Dropdown background font, loading chart style, only support dark/light
Enablepulldownrefresh Boolean False Whether to open the Drop-down refresh, see the page-related event handler function.

Tabbar

If our applet is a multiple tab application (the tab bar at the bottom of the client window is available to switch pages), we can specify the tab bar performance through the Tabbar configuration item, and the corresponding page to be displayed when the tab switch is available.

Tabbar is an array that can be configured with at least 2, up to 5 tab,tab sorted in order of array.

Property type Default Value Description
Color Hexcolor Is Default color for text on tab
Selectedcolor Hexcolor Is The color when the text on the tab is selected
BackgroundColor Hexcolor Is The background color of the tab
BorderStyle String Whether Black Tabbar color on border, only supports Black/white
List Array Is A list of tabs, as described in Listing properties, at least 2, up to 5 tabs
Position String Whether Bottom optional value bottom, top

Where list accepts an array, each item in the array is an object, and the property values are as follows:

Property type must fill Description
Pagepath String Is Page path, which must be defined first in pages
Text String Is button text on tab
IconPath String Is Picture path, icon Size limited to 40KB
Selectediconpath String Is Picture path When selected, icon size is limited to 40KB

You can set timeout times for various network requests.

Attribute Description:

Property type must fill Description
Request Number Whether Wx.request timeout, in milliseconds
Connectsocket Number Whether Wx.connectsocket timeout, in milliseconds
UploadFile Number Whether Wx.uploadfile timeout, in milliseconds
DownloadFile Number Whether Wx.downloadfile timeout, in milliseconds

Debug mode can be opened in the Developer tool, the console panel of the developer tool, the debugging information is given in the form of info, and the information has page registration, page routing, data update, event triggering.

Page.json

Each applet page can also use a. json file to configure the window performance for this page. The configuration of the page is much simpler than the App.json global configuration, which simply sets the contents of the window configuration item in App.json, and the configuration item in the page overrides the same configuration item in the App.json window.

Page's. JSON can only set window-related configuration items to determine the Windows performance of this page, so you do not have to write window this key, such as:

{"
 Navigationbarbackgroundcolor": "#ffffff", "
 Navigationbartextstyle": "Black",
 " Navigationbartitletext ":" Micro-communication Interface function demo, "
 backgroundcolor": "#eeeeee",
 "Backgroundtextstyle": "Light"
}

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.