Adding a global variable / function in JavaScript (specifically NativeScript)

后端 未结 1 1510
情话喂你
情话喂你 2021-01-04 15:18

I\'m learning how to write apps with NativeScript. I believe the best way to learn is by doing. For that reason, I\'m building a basic app.

In this app, I\'m trying

相关标签:
1条回答
  • 2021-01-04 15:40

    Use the global namespace. In your app.js, code:

    var application = require("application");
    application.mainModule = "main-page";
    
    global.myVariable = 'some value';
    
    application.start();
    

    You can then use global.myVariable anywhere in your app.

    0 讨论(0)
提交回复
热议问题