JS判定画像は全部ロード済みです.

666 ワード

コードを直接入れました

let mulitImg = [
    ... //      
]
let promiseAll = [],
    img = [],
    imgTotal = mulitImg.length

for (let i = 0; i < imgTotal; i++) {
    promiseAll[i] = new Promise((resolve, reject) => {
        img[i] = new Image()
        img[i].src = mulitImg[i]
        img[i].onload = function() {
            console.log(` ${i}     `)
            resolve(img[i])
        }
        img[i].onerror = function(err) {
            //    ,      
            this.src = "      "
        }
    })
}
Promise.all(promiseAll).then((img) => {
    console.log(...img, '      ')
})