[英]How to use global object in Angular?
There is a global object in window as "Apollo".窗口中有一个名为“Apollo”的全局对象。
I try to use it in Angular like Apollo.get()
and as types: function show(): Apollo.Data {}
.我尝试在 Angular 中使用它,比如Apollo.get()
和类型: function show(): Apollo.Data {}
。
How to do that?怎么做?
I have tried to determine:我试图确定:
typings.d.ts
With content:有内容:
declare var Apollo;
But inside Angular code I can not use it as type:但在 Angular 代码中,我不能将其用作类型:
let el:Apollo.Data.
And new Apollo.Geometry();
还有new Apollo.Geometry();
find out polyfills.ts
and end of the file place below Snippet.在 Snippet 下方找出polyfills.ts
和文件末尾。
declare global {
interface Window {
Apollo: any;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.