App({
// Lifecycle callback -- listens for applets initialization
onLaunch (options) {
},
// Lifecycle callback -- listens for applets to start or cut foreground
onShow (options) {
},
// Lifecycle callback -- listen for applets to cut background
onHide () {
},
// Error listener function
onError (msg) {
},
// There is no listener on the page
onPageNotFound (options) {
},
// Unprocessed Promises reject event listeners
onUnhandledRejection (options) {
},
// Listen for system theme changes
onThemeChange(options){},// Developers can add any function or data variable to the Object argument, which can be accessed with this
globalData: 'I am global data'
})
Copy the code
// Other js files get global variables
var appInstance = getApp()
console.log(appInstance.globalData) // I am global data
Copy the code