提交 a50ece94 编写于 作者: huangwensu's avatar huangwensu

图片上传添加宽高

上级 0f872f05
...@@ -188,7 +188,6 @@ export default { ...@@ -188,7 +188,6 @@ export default {
this.fileIndex = index; this.fileIndex = index;
}, },
uploadImportFile(file) { uploadImportFile(file) {
console.log("================",file)
let _this = this; let _this = this;
const isLt5M = file.size / 1024 / 1024 < 6; const isLt5M = file.size / 1024 / 1024 < 6;
if (!isLt5M) { if (!isLt5M) {
...@@ -200,12 +199,13 @@ export default { ...@@ -200,12 +199,13 @@ export default {
_this.searchParam.contentModelList[this.fileIndex].type = 1; // 图片 _this.searchParam.contentModelList[this.fileIndex].type = 1; // 图片
let imgFile = new FileReader(); let imgFile = new FileReader();
imgFile.readAsDataURL(file); imgFile.readAsDataURL(file);
imgFile.onload = function(e) { imgFile.onload = function(theFile) {
let image = new Image(); let image = new Image();
image.src = e.target.result; image.src = theFile.target.result;
image.onload = function() { image.onload = function() {
_this.searchParam.contentModelList[this.fileIndex].width = this.width; let cox = this;
_this.searchParam.contentModelList[this.fileIndex].height = this.height; _this.searchParam.contentModelList[_this.fileIndex].width = cox.width;
_this.searchParam.contentModelList[_this.fileIndex].height = cox.height;
} }
} }
}else if(file.type == 'application/pdf') { }else if(file.type == 'application/pdf') {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册