interview-answe icon indicating copy to clipboard operation
interview-answe copied to clipboard

[bug]239.Access to XMLHttpRequest at 'xxxx' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Open webVueBlog opened this issue 5 years ago • 1 comments

webVueBlog avatar Jun 28 '20 01:06 webVueBlog

var imgs = new Image();
imgs.crossOrigin = "Anonymous"; //注意存放顺序
imgs.src = "http://192.168.0.107/ZHCX/CGZSIMG/1.jpg";
imgs.onload = function () {
var canvas = document.createElement('canvas');
canvas.width = imgs.width;
canvas.height = imgs.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(imgs, 0, 0, imgs.width, imgs.height);
var img1 = new Image();
img1.src = canvas.toDataURL("image/png");
alert("s")
}

imgs.onerror = function () {
alert("error")
}

webVueBlog avatar Jun 28 '20 02:06 webVueBlog