function loadImageAsync(url) {
return new Promise(function(resolve, reject) {
throw new Error('BUG FOREVER')
const image = new Image();
image.onload = function() {
resolve(image);
};
image.onerror = function() {
reject(new Error('Could not load image at ' + url));
};
image.src = url;
});
}
let src1='https://image.suning.cn/uimg/sop/commodity/213287247648868791262800_x.jpg'
let src2='https://image.suning.cn/uimg/sop/commodity/742303264420020864606900_x.jpg'
let img1=loadImageAsync(src1)
let img2=loadImageAsync(src2)
img1.then(function(img){
console.log('第一个图片 height='+img.height)
return img2
}).then(function(img){
console.log('第二个图片 width='+img.width)
}).catch(function(err){
console.log('fail'+err)
})
牧羊人nacy
慕神8447489
相关分类