const isSize = new Promise(function(resolve, reject) {
let width = 60;
let height = 60;
let _URL = window.URL || window.webkitURL;
let img = new Image();
img.onload = function() {
debugger
let valid = img.width >= width && img.height >= height;
valid ? resolve() : reject();
}
img.src = _URL.createObjectURL(file);
}).then(() => {
return file;
}, () => {
this.$message.error('上传的icon必须是等于60*60!');
console.log(this.imgFileList);
this.hideUpload = false
this.imgFileList = [] //将上传的图片清空
return Promise.reject();
});
return isSize;
element-ui上传图片,限制图片尺寸,
最新推荐文章于 2022-10-25 17:09:09 发布