App()
App()
| onLaunch | Function | ||
| onShow | Function | ||
| onHide | Function | ||
| onError | Function | ||
| onPageNotFound | Function | ||
| Any |
App({ onLaunch: function(options) { // Do something initial when launch. }, onShow: function(options) { // Do something when show. }, onHide: function() { // Do something when hide. }, onError: function(msg) { console.log(msg) }, globalData: 'I am global data' })
| path | String | |
| query | Object | |
| scene | Number | |
| shareTicket | String | |
| referrerInfo | Object | |
| referrerInfo.appId | String | |
| referrerInfo.extraData | Object |
。
| 1020 | ||
| 1035 | ||
| 1036 | ||
| 1037 | ||
| 1038 | ||
| 1043 |
onPageNotFound
| path | String | |
| query | Object | |
| isEntryPage | Boolean |
App({ onPageNotFound(res) { wx.redirectTo({ url: 'pages/...' }) // 如果是 tabbar 页面,请使用 wx.switchTab } })
getApp()
getApp()
// other.js var appInstance = getApp() console.log(appInstance.globalData) // I am global data
转载请标明出处:注册程序
文章来源: 注册程序