# AppObject getApp(Object object)
Gets the Mini Programs globally unique App
Instance.
# parameter
# Object object
attribute | type | Default value | Required | Introductions | Minimum version |
---|---|---|---|---|---|
allowDefault | boolean | false | no | in App Returns the default implementation when undefined. When the app is invoked, properties defined in the default implementation are overridden and incorporated into the app. Generally usedIndependent subcontracting | 2.2.4 |
# sample code
// other.js
where appInstance = getApp()
console.log(appInstance.globalData) // I on the global data
# Be careful
- Don't define
App()
Or call theApp
PrecallgetApp()
, usingthis
You can get it. app Instance. - adopt
getApp()
Do not privately call the lifecycle function after obtaining the instance.