项目场景:
例如:上传多张,单张图片
问题描述
element ui 上传图片简单
原因分析:
自己使用自己写的方法,耗费时间长,并且功能有错
解决方案:
el-upload(
:action="globalPath.upFileUrl"
:headers="{ Authorization: token }"
:on-success="handleSewageSuccess"
:class="{ hide: knowledgeFile1 && knowledgeFile1.length > 0 }"
:on-remove="handlePaperRemove"
multiple
:limit="1"
:file-list="knowledgeFile1"
list-type="picture-card"
i class="el-icon-plus"
)
//文件上传成功
handleSewageSuccess(type, file) {
this.knowledgeFile1 = [];
this.dialogForm.picture = '';
let textT = JSON.parse(JSON.stringify(file));
this.knowledgeFile1.push(textT);
// console.log(this.knowledgeFile1, '0000');
this.dialogForm.picture = file.response.data.storeName;
}, //删除文件
handlePaperRemove(type, file, fileList) {
this.knowledgeFile1 = [];
this.dialogForm.picture = '';
},