

English
The getApp()
function is used to obtain the current application instance, generally used to obtain globalData.
Instance
const app = getApp()
console.log(app.globalData)
Notice:
getApp()
in a function defined in App()
or before calling App
, you can get the corresponding app instance through this.$scope
getApp()
, do not call the life cycle function privately.getApp()
in the home page nvue
, you may not necessarily get the real App
object. For this reason, const app = getApp({allowDefault: true})
is provided to obtain the original App
object, which can be used to initialize globalData
etc. on the homepage