原创

js-预加载图片资源

(function preloadImgs() {
    var preloadImgsArr  = [];
    if(signaturePhotoVoList && signaturePhotoVoList.length >0){
        preloadImgsArr = signaturePhotoVoList.slice();;
    }
    if(otherPhotoVoList && otherPhotoVoList.length >0){
        preloadImgsArr = preloadImgsArr.concat(otherPhotoVoList);;
    }
    if (preloadImgsArr.length > 0) {
        $.each(preloadImgsArr, function (index, item) {
            var img = new Image();
            img.src = item.photoUrl;
            if (img.complete) {
                console.log("已下载,不再下载"+img.src)
                return true;
            }
            console.log("未下载,下载"+img.src)
        });
    }
})();
正文到此结束
本文目录