let image = new Image();
let that = this;
image.crossOrigin = '';
image.src = url;
image.src = url + '?time=' + new Date().valueOf();
// 允许跨域操作
image.setAttribute('crossOrigin', 'anonymous');
image.onload = function() {
  let base64 = that.getBase64Image(image);
  let img2 = that.convertBase64UrlToBlob(base64);
  if (type === 1) that.changeKoubeiImg(1, img2);
  if (type === 2) that.changeKoubeiImg(2, img2);
};

 

setAttribute 解决了图片跨域问题,记录下

Logo

前往低代码交流专区

更多推荐