How to declare global variable in module script

纵然是瞬间 提交于 2020-07-03 09:26:08

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/48612021/how-to-declare-global-variable-in-module-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!