elementUi upload 删除文件缩略图
HTML:
<el-upload action="#" :before-upload="handleBeforeUpload" :on-change="handleFileChange" list-type="picture-card" :auto-upload="false" ref="upload" > <i slot="default" class="el-icon-plus"></i> <div slot="file" slot-scope="{ file }"> <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" /> <span class="el-upload-list__item-actions" style="width:100%,display:flex,align-items:center" > <span class="el-upload-list__item-delete" @click="handleRemove(file)" > <i class="el-icon-delete"></i> </span> </span> </div> </el-upload>
js:
handleRemove(file) { // this.$refs.upload.clearFiles() const uploadFiles = this.$refs.upload.uploadFiles; for (let i in uploadFiles) { if (file.url === uploadFiles[i].url) { uploadFiles.splice(i, 1); } } },