[英]Assigning a DOM object in TypeScript
I'm trying to assign the DOM object of a webpage to a TypeScript variable. 我正在尝试将网页的DOM对象分配给TypeScript变量。
protected DOM_obj : HTMLElement;
DOM_obj = document.defaultView;
I however seem to get the following error: 但是,我似乎得到以下错误:
Type 'Window' is not assignable to type 'HTMLElement'.
“窗口”类型不能分配给“HTMLElement”类型。 Property 'accessKey' is missing in type 'Window'.
“Window”类型中缺少属性“accessKey”。
How would I go about assigning the DOM object of the current window to a TypeScript variable? 我如何将当前窗口的DOM对象分配给TypeScript变量?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.