
<el-upload
class="upload-demo"
ref="upload"
:action="uploadFileUrl"
:on-remove="beforeRemove"
multiple
:limit="10"
:on-exceed="handleExceed"
:file-list="fileList"
:auto-upload="false"
:before-upload="beforeupload"
:on-success="handleUploadSuccess"
:headers="headers"
:http-request="httpRequest"
:on-change="handleChange"
name="files"
>
//移除文件
beforeRemove(file, fileList) {
console.log("file,filelist", file, fileList);
return this.$confirm(`确定移除 ${file.name}?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
// 去重,这块得把相同的url对比进行去除。要不然他是没有真正的删除。再次上传还是会出现之前删除的文件
let fileIndex = this.fileList.findIndex(
(item) => item.url == file.url
);
this.fileList.splice(fileIndex, 1);
})
.catch(() => {
this.$message({
type: "info",
message: "已取消移除",
});
});
},
版权声明:本文为szh1127249432原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。