多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ import 'babel-polyfill' function loadImg(src) { var promise = new Promise(function (resolve, reject) { var img = document.createElement('img') 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 src2 = 'https://img1.mukewang.com/545862fe00017c2602200220-100-100.jpg' const load = async function () { const result1 = await loadImg(src1) console.log(result1) const result2 = await loadImg(src2) console.log(result2) } load() ~~~