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?
According to online reports, more than 80 employe...
Toothache, the listener is sad and sheds tears Ho...
This article takes " Tencent Game Manager&qu...
Android and Apple have been fighting for so many ...
From whales that live like fish in the ocean, to ...
Pinduoduo's activity of getting 100 yuan for ...
I have tried Uber's services many times in th...
[[148867]] Since Google services have never been ...
The clothing category has always been a product w...
Local promotion is an effective way for App to ac...
Rockhopper penguins are small, with a body length...
A new year brings new prospects, and so does Appl...
Baiguoyuan is now No. 1 in the fruit industry. Wh...
In the past few days, Apple officially announced ...
Recently, the Hotan-Ruoqiang Railway in Xinjiang ...