<el-upload
:class="uploadDisabled1 ? 'disabled1' : ''"
action="/" //不重要
list-type="picture-card"
:file-list="fileList"
:on-remove="handleRemove1"
:http-request="httpRequest1">
<i class="el-icon-plus"></i>
</el-upload>
httpRequest1(file) {
if (
file.file.type == "image/jpeg" ||
file.file.type == "image/png" ||
file.file.type == "image/JPG" ||
file.file.type == "image/jpg" ||
file.file.type == "image/PNG" ||
file.file.type == "image/JPEG"
) {
var isImage = true;
} else {
isImage = false;
this.$nextTick(() => {
$("#icon1 .el-upload-list--picture-card li").remove();
});
}
let isLt30K = file.file.size < 30 * 1024;
if (!isImage) {
this.$message.error("只能上传图片格式png、jpg、gif!");
return;
}
if (!isLt30K) {
this.$message.error("只能上传图片大小小于30K");
this.$nextTick(() => {
$("#icon1 .el-upload-list--picture-card li").remove();
});
return;
}
var This = this;
var reader = new FileReader();
reader.readAsDataURL(file.file);
reader.onload = function(e) {
this.result;
This.strategyUpdata.openIcon = this.result;
This.uploadDisabled1 = true;
This.fileList.push({ url: this.result });
console.log(This.fileList);
};
},
handleRemove1(file, fileList) {
this.strategyUpdata.openIcon = "";
this.uploadDisabled1 = false;
this.fileList = [];
},