1.在el-upload的元素加上:
ref="upload"
2.在删除方法里面这样写:
handleRemove(file) {
let fileList = this.$refs.upload.uploadFiles;
let index = fileList.findIndex( fileItem => {return fileItem.uid === file.uid});
fileList.splice(index, 1);
},
即可解决!
本文介绍了一种在el-upload组件中实现文件删除的方法。通过在上传组件上设置引用(ref)并利用该引用操作文件列表,实现了指定文件的移除功能。
1.在el-upload的元素加上:
ref="upload"
2.在删除方法里面这样写:
handleRemove(file) {
let fileList = this.$refs.upload.uploadFiles;
let index = fileList.findIndex( fileItem => {return fileItem.uid === file.uid});
fileList.splice(index, 1);
},
即可解决!
1086

被折叠的 条评论
为什么被折叠?