💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
![](https://img.kancloud.cn/67/f2/67f2e157a224947c4c633b7e62981ceb_722x437.png) ![](https://img.kancloud.cn/ea/8d/ea8dc165685b5e8af72f6c282f0baa45_714x434.png) ``` function loadImg(src) { var promise = new Promise(function (resolve, reject) { var img = document.createElement('img') // throw new Error('.....') img.onload = function () { resolve(img) } img.onerror = function () { reject('图片加载失败') } img.src = src }) return promise } ``` ``` var src1 = 'https://www.imooc.com/static/img/index/logo_new.png' var result1 = loadImg(src1) var src2 = 'https://img1.mukewang.com/545862fe00017c2602200220-100-100.jpg' var result2 = loadImg(src2) Promise.all([result1, result2]).then(function (datas) { console.log('all', datas[0]) console.log('all', datas[1]) }) Promise.race([result1, result2]).then(function (data) { console.log('race', data) }) ```