In the early morning of September 22, WeChat public platform sent a test invitation to 200 service accounts for "WeChat Mini Program". WeChat said that "Mini Program" is currently only in the testing stage, and in the future, the subjects of such "Mini Program" will be more extensive, whether individuals, governments, enterprises, media, or other organizational developers, all can apply to register and use "Mini Program". After the release of "Mini Program", it has set off a great response in the industry. The following is a brief summary of my initial research. Development Tools Download Directory Structure We create a new project in the development tools provided by WeChat. The development tools will establish a basic directory structure and sample Demo code for us. The structure is as follows: The structure is very simple. The main part of the program consists of three files: app.js, app.json, and app.wxss, and they must be placed in the root directory of the project. The page consists of four files: Configuration
Logical Layer 1. Registration Procedure The App() function is used to register a mini program. It accepts an object parameter that specifies the mini program's life cycle functions, etc. Example:
2. Registration page The Page() function is used to register a page. It accepts an object parameter that specifies the page's initial data, lifecycle functions, event handling functions, etc.
3. Modularity Some common codes can be extracted into a separate js file as a module. The module can only expose the interface to the outside world through module.exports or exports. It should be noted that:
4. API The mini program development framework provides a rich set of WeChat native APIs, which can easily call up the capabilities provided by WeChat, such as obtaining user information, local storage, payment functions, etc. 5. ES6 to ES5 WeChat Mini Programs run on three platforms: iOS, Android, and developer tools for debugging
Although the three runtime environments are similar in most cases, there are still some subtle differences. In order to help developers solve the problems caused by these differences, the development tools will automatically help developers convert ES6 code to ES5 code. For developers who use other build tools, you can turn off this feature in the project and use your own build and transcoding tools. View Layer Contrary to my previous intuition about WeChat Mini Programs, WeChat Mini Programs do not support nor are they compatible with HTML. Instead, they are newly defined specifications by WeChat. The suffix of its view files is .wxml, which is an extension based on XML. Its style sheet file is not CSS, but .wxss, which is compatible with some limited CSS writing methods. When rendering the view, a one-way data binding method is used for data binding. The dynamic data in WXML comes from the data of the corresponding Page. Use Mustache syntax (double curly braces) to wrap the variables:
The framework makes it very easy to keep data and views in sync. When modifying data, you only need to modify the data in the logic layer, and the view layer will be updated accordingly. Supports conditional rendering, list rendering, templates, and events WXSS (WeiXin Style Sheets) is a style language used to describe the component styles of WXML. WXSS is used to determine how WXML components should be displayed. WXSS has most of the features of CSS. At the same time, in order to be more suitable for the development of WeChat applets, we have expanded and modified CSS. Compared with CSS, our extended features are:
The framework provides developers with a series of basic components, which can be combined for rapid development. Component Documentation WeChat Mini Program Official Document Portal |
<<: Android unit testing - several important issues
>>: Handler, Looper and MessageQueue source code analysis
"Public toilets" have always been a con...
As a long-term project with a relatively low thre...
The Internet is a very magical world. As long as ...
If a product is created to solve a certain pain p...
Friends often ask, what are the differences in th...
According to the Times of India, the Indian gover...
Recently, the "Artemis 1" has come to a...
summary: To help you understand the relevant know...
What I talk about most with friends recently is K...
The development of technology companies also has ...
Mr. Huang's Qi Zong Writing Training Camp Res...
When flying on an airplane, many passengers prefe...
In order to improve everyone's input efficien...
The development of the Xing'an League geotech...