new Image()

var img=new Image();

img.src="xxx";

获取img.width和img.height的值都为0,后来发现它的宽和高需要在img.onload图片加载完全后才能得到。

原文地址:https://www.cnblogs.com/beng/p/3504042.html