简体   繁体   中英

How to declare global variable in module script

I have a module script, in which I import some classes and initialize my app. But module scipts declare var myVar = "my"; in module context, what makes init variables unaccessible to main app code. But I don't know how to declare global variable in module script.

Instead of var myVar = "my"; use window.myVar = "my";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM