javascript to achieve pre-loaded images

function load(url) {
    imgObj the let = new new Image (); // create a picture object 
    imgObj.src = url;
     IF (imgObj.complete) {
        console.log('is loaded')
    } else {
        imgObj.onload = () => {
           console.log('loading success')
        };
        imgObj.onerror = () => {
            console.log('loading error')
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/223zzm/p/11666334.html