在模块内部调用全局变量 [英] Call a global variable inside module
本文介绍了在模块内部调用全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为 Projects.ts
的打字稿文件,我想引用一个在名为 bootbox.js
的引导插件中声明的全局变量.
I have a typescript file called Projects.ts
that I want to reference a global variable declared in a bootstrap plugin called bootbox.js
.
我想从 TypeScript 类中访问一个名为 bootbox
的变量.
I want to access a variable called bootbox
from within a TypeScript classes.
有可能吗?
推荐答案
你需要告诉编译器它已经声明:
You need to tell the compiler it has been declared:
declare var bootbox: any;
如果你有更好的类型信息,你也可以添加它,代替 any
.
If you have better type information you can add that too, in place of any
.
这篇关于在模块内部调用全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文