We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
图片展示屏幕上会有一个 decode(解码)的过程,如果是大图片的话,解码速度会相当慢。由于解码是同步的,所有这个时候主线程会被阻塞,从来没法完成任何操作。所以就需要异步解码图片。
decode
function prepareImage() { var img = new Image(); img.src = "nebula.jpg"; img.decode().then(function() { document.body.appendChild(img); }); }
或者使用 async属性
// 打开异步解码 <img async=on src="space.jpg" > //关闭异步解码 <img async=off src="space.jpg">
使用异步 decode 将不会阻塞主线程 异步: 同步:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
异步 decode
图片展示屏幕上会有一个
decode
(解码)的过程,如果是大图片的话,解码速度会相当慢。由于解码是同步的,所有这个时候主线程会被阻塞,从来没法完成任何操作。所以就需要异步解码图片。或者使用 async属性
使用异步
decode
将不会阻塞主线程异步:
同步:
The text was updated successfully, but these errors were encountered: