Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the Wechat APP life cycle and page life cycle?

Shulou Source: shulou.com Published: 2022-05-31 21:08:55 10月03日 Update

This article introduces the knowledge of "what is the life cycle of Wechat APP and what is the life cycle of the page?" in the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The startup process of Mini Program

Let's draw a picture to show the whole Mini Program startup process, and we will know:

App lifecycle

To execute the App () function is to register an App

1 when registering for app, you can judge the entry scene of Mini Program.

2 We can make some data requests through the life cycle function.

3 you can set a global object in app so that all pages can use it.

Life cycle Page of the page (initial data of the page * / data: {}, / * Life cycle function-listening page load * / onLoad: function (options) {console.log ("onload")}, / * Life cycle function-listening page display * / onShow: function () {console.log ("onshow")} / * Lifecycle function-first rendering of listening page completed * / onReady: function () {console.log ("onReady")}, / * Lifecycle function-listening page hiding * / onHide: function () {console.log ("onHide")} / * Lifecycle function-- unload the listening page * / onUnload: function () {console.log ("onUnload")}, / / listen for the user drop-down action OnPullDownRefresh: function () {/ / if you want to use this, you must use "enablePullDownRefresh": true console.log ("pull down")}, / / the handler function onReachBottom:function () {console.log ("pull up to the bottom")}, / / the handler function of the page scroll trigger event onPageScroll: function (e) {console.log ("the wheel is understanding", e)})

1 send a network request in the lifecycle function to obtain data from the server

2 initialize some data in data to facilitate wxml reference

3 listen for wxml events and bind corresponding event functions

4 there are page scrolling, pull-up, pull-down, etc.

The life cycle of the page (figure)

This is the end of the content of "what is the life cycle of Wechat APP and the life cycle of the page". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Cycle life page function cycle function monitor event data program drop-down content more process knowledge processing practical learning and then that is the overall situation. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL vpn macOS Apple