Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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. #239

Open
webVueBlog opened this issue Jun 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@webVueBlog
Copy link
Member

No description provided.

@webVueBlog webVueBlog added the bug Something isn't working label Jun 28, 2020
@webVueBlog webVueBlog changed the title [bug] [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. Jun 28, 2020
@webVueBlog
Copy link
Member Author

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")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant