图片已经设置了跨域,请求图片时候还是报不允许跨域,这个时候要检查getImageBlob方法的上边是不是有console.log方法,如果有删掉即可!这个坑,记录一下
getImageBlob(url, cb) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'blob';
xhr.onload = function() {
if(this.status == 200) {
var img = new Image();
img.onload = function() {
if(cb) {
cb(img)
}
}
img.src = URL.createObjectURL(this.response);
}
};
xhr.send();
},