uploadImg(e,record,index){constfile=e.target.files[0];//判断上传图片的大小限制if(file.size/1024<1000){constthat=this;让imgWidth="";让imgHight="";//将图像大小限制为2000*1500constisSize=newPromise(function(resolve,reject){const_URL=window.URL||window.webkitURL;constimg=newImage();img.onload=function(){imgWidth=img.width;imgHight=img.height;constvalid=img.width===parseInt(2000)&&img.height===parseInt(1500);valid?resolve():reject();};img.src=_URL.createObjectURL(file);}).then(()=>{constformData=newFormData();formData.append("files",file);that.loading=true;//这是调用接口interfacename(formData).then(res=>{//that.$message.success("图片上传成功");}).finally(()=>{that.loa叮=假;});},()=>{//图片尺寸错误提示this.$message.info(`图片尺寸应为2000x1500,当前图片尺寸为${imgWidth}x${imgHeight}`);返回Promise.reject();});}else{this.$message.info("最大图片大小为1000k");}}
