当我在浏览器中收到文件丢弃时,我得到一个 FileList目的。这种类型的目的是什么?据我所知,它几乎与 Typescript File[]
或一个很好的旧 JavaScript 文件对象数组相同。
据我所知,FileList 较差,因为您不能使用其中之一迭代值或索引
for (let file of files) {
// read file
}
for (let index in files) {
// read files[index]
}
我也没有看到历史原因,因为 Array的 File应该至少和 FileList 一样长。
我是不是漏掉了什么?
看来您完全正确 - 来自 official specification :
Note: The FileList interface should be considered "at risk" since the general trend on the Web Platform is to replace such interfaces with the Array platform object in ECMAScript [ECMA-262]. In particular, this means syntax of the sort filelist.item(0) is at risk; most other programmatic use of FileList is unlikely to be affected by the eventual migration to an Array type.
这个接口(interface)比较老,和NodeList很像尽管后者有点现代化。