(2) Life cycle of WeChat mini program

1. The applet has its life cycle. Until the entire applet is destroyed, its life cycle ends. However, each interface also has its life cycle, the creation and destruction of the interface. All go through these processes.

2. Register the mini program. App (Object object) accepts an Object parameter and specifies the life cycle callback of the mini program. The App() callback in the app.js file in the project root directory must be called and can only be called once.

When you start the mini program, the log will be printed out.

3. The following official website: https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html . Parameters of the provided Object object

4. When registering a mini program page, accept an Object type parameter and specify the initialization data, life cycle, event processing and delivery of the page. Page(Object object) in the xxx.js file of each page 

 calling code

// logs/logs.js

Page({

 

/**

* Initial data of the page

*/

data: {

 

},

 

/**

* Life cycle function--listen to page loading

*/

onLoad: function (options) {

 

},

 

/**

* Life cycle function--listen to the completion of the initial rendering of the page

*/

onReady: function () {

 

},

 

/**

* Life cycle function--monitoring page display

*/

onShow: function () {

 

},

 

/**

* Life cycle function--listen to page hiding

*/

onHide: function () {

 

},

 

/**

* Life cycle function--listen for page unloading

*/

onUnload: function () {

 

},

 

/**

* Page related event processing function--monitor the user's pull-down action

*/

onPullDownRefresh: function () {

 

},

 

/**

* Handling function for page pull-down event

*/

onReachBottom: function () {

 

},

 

/**

* User clicks on the upper right corner to share

*/

onShareAppMessage: function () {

 

}

})

Write corresponding business logic during its life cycle.

The above is the life cycle of WeChat applet. As important as the life cycle of Android. Master it well and perform corresponding data processing in each period.

 

 

Guess you like

Origin blog.csdn.net/beautifulYuan/article/details/99411698