[英]For the upload of ant-design-vue (version 3.x), how to click the button to perform "re-upload operation" when the upload fails
The current implementation is as follows: 1: Use custom upload 2: Using a custom list item, this part can add the function of re-uploading, but the file in itemRender cannot be used目前实现如下: 1:使用自定义上传 2:使用自定义列表项,这部分可以添加重新上传的功能,但是itemRender中的文件不能使用
<reload-outlined v-show="file.status === 'error'" @click="filesUpload(file)" />
<template>
<a-upload
:multiple="true"
:max-count="5"
:file-list="fileLists"
:rules="[{ required: true, message: 'Please select upload file!' }]"
style="height: 100px; min-height: 100px; max-height: 350px"
:before-upload="beforeUpload"
:custom-request="filesUpload"
@change="checkFiles"
>
<a-button>
<upload-outlined></upload-outlined>
select file
</a-button>
...
</a-upload>
</template>
const checkFiles = ({ file, fileList }) => {
...
}
const filesUpload = async (file) => {
const formData = new FormData()
formData.append('file', file.file)
formData.append('type', file.file.name.split('.').pop())
formData.append('bucketName', 'knowledge')
file.onProgress()
const onUploadProgress = (progressEvent) => {
let progressPercent = parseInt(((progressEvent.loaded / progressEvent.total) * 100).toFixed(2))
file.onProgress({ percent: progressPercent })
}
}
</script>
You have already implemented manual upload filesUpload
, then you only need to call filesUpload
.您已经实现了手动上传
filesUpload
,那么您只需要调用filesUpload
。
Your current file is an internal variable, you need to store it globally, so that you can re-pass it in the second call.您当前的文件是一个内部变量,您需要全局存储它,以便您可以在第二次调用中重新传递它。
If it still doesn't work, you can make jsrun for us to debug online如果还是不行,可以制作jsrun让我们在线调试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.