我尝试过How should customRequest be set in the Ant Design Upload component to work with an XMLHttpRequest?,但它不适用于ant design vue。有人能写一个例子吗?
发布于 2020-02-27 17:38:34
这是HTML组件:
<a-upload-dragger
name="file"
:multiple="true"
:customRequest="uploadfiles"
@change="handleChange">
</a-upload-dragger>您需要处理customRequest:
uploadfiles({ onSuccess, onError, file }) {
this.upload(file)
.then(() => {
onSuccess(null, file);
})
.catch(() => {
console.log('error');
});
};文件具有这样的结构:
name: "YourFileName.txt"
lastModified: ...
lastModifiedDate: ...
webkitRelativePath: ""
size: 24
type: "text/plain"
uid: "vc-upload-xxxxxx..."您可以实现自己的上传功能。
您可以处理文件上传进度的状态变化:
handleChange(info) {
const status = info.file.status;
if (status !== 'uploading') {
// show update progress console.log(info.file, info.fileList);
}
if (status === 'done') {
// show success message
} else if (status === 'error') {
// show error message
}
}https://stackoverflow.com/questions/59816834
复制相似问题