Open klren0312 opened 4 months ago
const checkImgWidthHeight = (theFile: File, width: number, height: number) => { return new Promise((resolve) => { const reader = new FileReader() reader.onload = (e) => { const img = new Image() img.onload = () => { if (img.width === width && img.height === height) { console.log('图片尺寸正确') resolve(true) } else { resolve(false) } } img.src = e.target?.result as string } reader.readAsDataURL(theFile) }) }