Can the Global Variables Defined in the app.ux File of a Quick App Be Read in the JavaScript File?

Search This thread

Mayism

Senior Member
Nov 5, 2020
133
26
github.com
The global variables defined by the quick app in app.ux can be obtained by using the common method getApp() in the JavaScript file. For details, refer to the sample code:

app.ux file:
JavaScript:
data: {
      AppData: '123456',
}

JavaScript file:
JavaScript:
export default {
      getAppData() {
        return getApp().$def.data.AppData
      }
    }

For more details, please refer to:
Quick app materials: https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-introduction
Quick app script:
https://developer.huawei.com/consumer/en/doc/development/quickApp-References/quickapp-script