输入'any [] | HTMLCollectionOf <Element>'必须具有'[Symbol.iterator]()'

时间:2019-12-24 08:11:59

标签: javascript html htmlelements

有以下JS查询:

const conditions = this.conditionBlock.getElementsByClassName(style.Condition) || [];

下面我尝试迭代条件:

for (const condition of conditions) {
}

所以,我得到一个错误:

Type 'any[] | HTMLCollectionOf<Element>' must have a '[Symbol.iterator]()' method that returns an iterator.

如何解决?

位置:

private conditionBlock: HTMLElement;

还有

getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;

0 个答案:

没有答案