圖片已經設置了跨域,請求圖片時候還是報不允許跨域,這個時候要檢查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();
},