<template>
<el-upload
actions="#"
:http-request="uploadFile"
:mulitiple="true"
:auto-upload="true"
:file-list="fileList"
:on-change="handleChange"
:show-file-list="false"
>
<el-button>上传附件</el-button>
</el-upload>
</template>
<script>
export default {
data() {
return {
fileList: []
}
},
methods: {
handleChange(file, fileList) {
this.fileList = fileList
},
uploadFile(file) {
const formData = new FormData()
this.fileList.map((file) => {
formData.append('file', file.raw)
})
// 执行axios请求
}
},
}
</script>
上面是代码
现在的问题是 上传多个文件的时候回调用多次接口,比如上传三个文件就回调用三次axios请求
现在需要解决的是 上传多个文件只执行一次axios请求
您可以看下,不知道这里是否能满足您的需求。
https://blog.csdn.net/m0_38039437/article/details/128579034