Skip to main content
Version: v2

getApp

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Get the app instance object.

Type

function getApp(): Result

Parameters

Result

PropertyTypeDescriptionAPI_LEVEL
_optionsOptionsapp instance property2.0

Options

PropertyTypeDescriptionAPI_LEVEL
globalDataobjectmounted data objects on app instances2.0

Example

App({
globalData: {
text: 'Hello Zepp OS',
},
onCreate() {
console.log('onCreate')
console.log(this.globalData.text)
},
onDestroy() {
console.log('onDestroy')
},
})

const app = getApp()
console.log(app._options.globalData.text)