图片跨域携带cookie
作者:
爱代码的派派星 | 来源:发表于
2019-10-11 11:10 被阅读0次 function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, img.width, img.height);
var dataURL = canvas.toDataURL("image/png");
return dataURL
}
const img = document.createElement('img');
img.crossOrigin = "use-credentials"; //注意存放顺序
img.src = this.host + '/captcha?merchantNum=' + this.merchantNum + '&tamp=' + this.timeTamp;
img.onload = ()=>{
this.imgSrc = getBase64Image(img);
this.imageLoad = false;
}
img.onerror = ()=>{
this.imageLoad = false;
this.getImg();
}
//img.crossOrigin = "Anonymous" img.crossOrigin = "use-credentials";
本文标题:图片跨域携带cookie
本文链接:https://www.haomeiwen.com/subject/cjrtmctx.html
网友评论