function preload(imgs, callback, end) { var len = imgs.length; var loaded = 0; for (var i = 0; i < len; i++) { (function(i) { var img = new Image(); img.onerror = img.onload = function() { loaded++; end ? loaded === len && callback(loaded, i) : callback(loaded, i) }; img.src = imgs[i]; })(i); } }
米脂
相关分类