在我的 TypeScript
类中,我有一个 JQuery
元素数组,通过调用来填充
this.$elements = $sourceElement.find(`[data-filter-element]`).toArray();
而 $elements : JQuery[];
是这样定义的。
问题是当我尝试迭代这些元素时:
this.$elements.forEach((current) => {
var $current = $(current); // <-- why do I have to do this?
// ...
});
为什么此处的 current
类型 (JQuery
) 不正确?
我也尝试过使用
for(let current of this.$elements){
// same issue here
}
以及
$.each(this.$elements, (idx, current) => {
// same issue here
});
最佳答案
关于javascript - TypeScript 中的 JQuery 元素数组在迭代时类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45233574/