A FileList
不是Array
,但确实符合其合同(具有length
数字索引),因此我们可以“借用” Array
方法:
Array.prototype.forEach.call(field.photo.files, function(file) { ... });
由于您显然正在使用ES6,因此还可以Array
使用新Array.from
方法将其设置为适当的:
Array.from(field.photo.files).forEach(file => { ... });
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句