<el-upload
:action="$upLoad"
:limit="3"
:show-file-list="true"
:file-list="fileList"
:ref="'el-upload'+count"
list-type="picture-card"
:auto-upload="true"
:before-upload="beforeUpload"
multiple
:on-exceed="handleExceed"
:on-success="handleSuccess"
:on-remove="handleRemove"
:on-change="handleChange"
>
...
</el-upload>
//成功回调方法
handleSuccess(response, file, fileList){
fileList.map((item)=>{
if(item.response){
this.fileList.push({
name:file.name,
url: response.data[0].url,
fileType:fileInfo.fileType(file)
});
}
})
}
当我在上传成功回调方法里给自己想要的处理的数据赋值 ,也就是this.fileList,造成上图的问题
由于手动赋值,同时造成错误判断,多张上传只执行一次成功回调。如果不对this.fileList操作的话,是会多次回调的
造成上面问题在于在成功回调那里,手动给动态的file-list 赋值了。
解决办法 在on-change的回调里写就没问题
handleChange(file,fileList){
this.fileList = fileList
}