Can't use forEach with Filelist

前端 未结 6 494
栀梦
栀梦 2020-12-23 08:56

I\'m trying to loop through a Filelist:

console.log(\'field:\', field.photo.files)
field.photo.files.forEach(file => {
   // looping code
})
         


        
6条回答
  •  时光说笑
    2020-12-23 09:15

    The lodash library has a _forEach method that loops through all collection entities, such as arrays and objects, including the FileList:

    _.forEach(field.photo.files,(file => {
         // looping code
    })
    

提交回复
热议问题