获得过 0 次赞
回答过的问题获得 0 次赞
分享过的文章/案例获得 0 次赞
评论与回复获得 0 次赞
naturalWidth和naturalHeight的原因,替换成width和height就行了
IOS 14.x 版本 canvas.toDataURL 返回 data:; ,其它平台正常。?function compressImage(file){ let cvs = document.getElementById('compress-canvas'); let newImage = new Image(); let fileCache = file; newImage.src = file.content; newImage.onload = () => { if (newImage.complete) { cvs.width = newImage.naturalWidth; cvs.height = newImage.naturalHeight; cvs.getContext('2d').drawImage(newImage, 0, 0, newImage.naturalWidth, newImage.naturalHeight); const newImageData = cvs.toDataURL(mime_type, 0.5); // newImageData 居然为data:; } }; }
2022-04-11