[英]iOS - Safari - images not rendering fully / cut off
這似乎是 iOS 圖像解碼器中的一個問題——某種競爭條件。
這已通過強制解碼器在主線程上操作來解決,使用:
<img decoding="sync" src="@Url" />
希望這對其他人有幫助!
在我同時加載大量圖像的情況下,在img
標簽上設置decoding="sync"
並沒有幫助。 之前手動加載圖像可以解決問題。
const imageLoader = new Image();
imageLoader.src = url;
imageLoader.decoding = 'sync';
imageLoader.onload = () => {
// allow drawing image
};
對於任何偶然發現這一點並在反應環境中工作的人
const [didLoadMainImage, setDidLoadMainImage] = useState(false);
useMemo(() => {
setDidLoadMainImage(false);
const imageLoader = new Image();
imageLoader.src = url;
imageLoader.decoding = 'sync';
imageLoader.onload = () => {
setDidLoadMainImage(true);
};
}, [url]);
return (
<div>
{didLoadMainImage ? (
<img src={url} />
) : null}
</div>
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.