vue如何判断图片已经加载完成?

Posted 醉笑三千席〆

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue如何判断图片已经加载完成?相关的知识,希望对你有一定的参考价值。

const imgs = [

\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\',
\'https://inews.gtimg.com/newsapp_bt/0/9906123226/1000\'

];

function ready(pics) {

const picsAll = pics.map((imgurl) => {
    imgurl = imgurl + \'?v=\' + Math.random(); // 仅是为了区分下不同的图片链接
    return new Promise((resolve, reject) => {
        const img = new Image();
        img.src = imgurl;
        img.onload = () => resolve(imgurl);
        img.onerror = () => reject(new Error(imgurl + \' load error\'));
    })
});
Promise.all(picsAll).then(() => {
    console.log(\'load all success\');
}).catch((e) => {
    console.log(e);
})

}

以上是关于vue如何判断图片已经加载完成?的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript判断图片是否已经加载完毕的方法汇总

vue页面加载完成自动执行方法是啥?

js判断图片是否已经加载(下载)完

如何判断网页是不是加载完毕

selenium+python,如何判断一个页面已经加载完成?

javascript判断图片是否加载完成方法整理