Used to register a small program. Call it when the applet starts, and create the applet until it is destroyed. It exists throughout the lifecycle of a applet. Obviously, it is single-instance and global.
I. App ()
Used to register a small program. Call it when the applet starts, and create the applet until it is destroyed. It exists throughout the lifecycle of a applet. Obviously, it is single-instance and global. So,
1) it can only be registered once in app. js.
2) you can use getApp () to obtain the unique small program Singleton anywhere in the code,
For example, var appInstance = getApp ();
The parameter of App () is object type {} and specifies the declaration cycle function of the applet.
OnLaunch function
Initialize the listener applet.
When the applet initialization is complete, onLaunch is triggered (only once globally ).
OnShow function
Listener applet display.
It is triggered when the applet is started or enters the foreground from the background.
OnHide functions
Hide the listener applet.
It is triggered when the applet enters the background from the foreground.
The definition of the frontend and backend is similar to that of an app on a mobile phone. for example, the app enters the background when it is not in use.
GlobalData object
Global Data.
The following figure shows the code and log reference:
OnLoad, onshow;
Otherwise, onShow
OnHide
More tutorials on small program development-Overview of App () and Page () functions. For more information, see PHP!