ImgSrc =['img/xx.png','img/xxx.png'...] Callback is a function that you execute after loading the image
function imgLoad(imgSrc,callback) {var imgs = [];
    var c = 0;
    for (var i = 0; i < imgSrc.length; i++) {
        imgs[i] = new Image();
        imgs[i].src = imgSrc[i];
        imgs[i].onload = function(){
            c++
            if(c == imgSrc.length){
                if(callback){ callback(); }}}}returnimgs;// Returns a list of loaded images
}
Copy the code