官方文档说
onChange
上传中、完成、失败都会调用这个函数。
文件状态改变的回调,返回为:
{
file: { /* ... */ },
fileList: [ /* ... */ ],
event: { /* ... */ },
}
只有uploading状态,最后每一次重新赋值给fileList后才可以正常回调。
const [fileList, setFileList] = useState<UploadFile[]>([]);
const handleChange: UploadProps['onChange'] = ({ file, fileList }) =>{
setFileList(fileList)
if(file.status === 'done'){
console.log(fileList);
console.log(file.response.data.url)
}
}