【发布时间】:2016-10-23 19:11:06
【问题描述】:
鉴于下面的 javascript,是否有相应的 TypeScript 来做同样的事情?
我只需要扩展 html dom 元素原型,但无法找出正确的 TypeScript 来执行此操作而不会出现编译错误。
Element.prototype.astyle = function actualStyle(props) {
var el = this;
var compStyle = window.getComputedStyle(el, null);
for (var i = 0; i < props.length; i++) {
var style = compStyle[props[i]];
if (style != null) {
return style;
}
}
return null;
};
【问题讨论】:
标签: javascript html node.js typescript prototype