Typescript: 错误:for..of 不适用于 NodeList

创建于 2016-11-04  ·  1评论  ·  资料来源: microsoft/TypeScript



打字稿版本:每晚(2.1.0-dev.201xxxxx)

代码

// A *self-contained* demonstration of the problem follows...
for(const a of document.querySelectorAll('div')) {}

预期行为:
它应该编译。

实际行为:
error TS2495: Type 'NodeListOf<Element>' is not an array type or a string type

Duplicate

最有用的评论

image

>所有评论

image

此页面是否有帮助?
0 / 5 - 0 等级