【发布时间】:2022-09-22 23:37:47
【问题描述】:
如何从函数getImgSize(imgSrc) 返回height?请记住,onload() 是异步的。
function getImgSize(imgSrc) {
const img = new Image();
img.onload = function() {
const height = img.height;
}
img.src = url;
}
-
您不能从事件处理程序返回任何内容。您试图在这里解决的实际问题是什么?
-
我拿了 20 张照片。我想将它们从最小的一个到最大的一个。排序后,我想显示它。
标签: javascript asynchronous return onload onload-event