Dongguan mini program development framework interface App and getApp parameters, register mini program. Accepts an Object parameter, which specifies the life cycle callback of the applet, etc. App() must be called in app.js and must be called and can only be called once. Otherwise there will be unpredictable consequences. App(Object object) parameterObject object
Sample CodeApp({ onLaunch (options) { // Do something initial when launch. }, onShow (options) { // Do something when show. }, onHide () { // Do something when hide. }, onError (msg) { console.log(msg) }, globalData: 'I am global data'}) onLaunch(Object object)Triggered when the mini program is initialized, and only triggered once globally. Parameters can also be obtained using wx.getLaunchOptionsSync. Parameters: Same as wx.getLaunchOptionsSync onShow(Object object)Triggered when the applet is started or enters the foreground from the background. You can also use wx.onAppShow to bind the listener. Parameters: Same as wx.onAppShow onHide()Triggered when the applet enters the background from the foreground. You can also use wx.onAppHide to bind the listener. onError(String error)Triggered when a script error or API call error occurs in the mini program. You can also use wx.onError to bind the listener. Parameters: Same as wx.onError onPageNotFound(Object object)
Triggered when the page that the applet wants to open does not exist. You can also use wx.onPageNotFound to bind the listener. Please refer to wx.onPageNotFound for precautions. Parameters: Same as wx.onPageNotFound Sample code: App({ onPageNotFound(res) { wx.redirectTo({ url: 'pages/...' }) // If it is a tabbar page, please use wx.switchTab }}) AppObject getApp(Object object)Get the globally unique App instance of the Mini Program. parameterObject object
Sample Code// other.jsvar appInstance = getApp()console.log(appInstance.globalData) // I am global data Notice
|
<<: Complete review: How to write an attractive information flow idea?
>>: How to use Tencent’s information flow advertising to win the Double 11 battle for traffic?
When selling insurance, we always encounter vario...
Data analysis, as a core skill that operations pe...
Course Contents: 00. Introduction to MBK Full Cour...
On September 30, a Zhihu user said that he had re...
When it comes to the number of APP downloads, tho...
Not long ago, three children were washed away by ...
Recently, Google reiterated that the China Teleco...
Sleeping is a simple thing. For young people, get...
The launch of WeChat public accounts has led to t...
Along with summer comes people's endless enth...
The "strong winds and waves" mentioned ...
On July 20, the Provincial Admissions Examination...
This explosive traffic platform, with its huge ce...
Author: Liu Su (Shanghai Chenshan Botanical Garde...
In the current Internet environment, user operati...