企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
![](https://img.kancloud.cn/8d/c8/8dc834ce5e70aa1523a78df2adcd5f74_614x385.png) ~~~ <p>promise test</p> <!-- <script src="https://cdn.bootcss.com/bluebird/3.5.1/bluebird.min.js"></script> --> <script type="text/javascript"> 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 src = 'https://www.imooc.com/static/img/index/logo_new.png' // var result = loadImg(src) // result.then(function (img) { // console.log(1, img.width) // return img // }, function () { // console.log('error 1') // }).then(function (img) { // console.log(2, img.height) // }) </script> ~~~