Promise对象加载图片

var preloadImage = function (path) {
  return new Promise(function (resolve, reject) {
    var image = new Image();
    image.onload  = resolve;
    image.onerror = reject;
    image.src = path;
  });
};
preloadImage('1-130525231320.jpg').then(()=>console.log('success')).catch(()=>console.log('error'));
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页