我正在阅读S3
的图像,我正在使用angularjs,当我打开页面时,我收到错误
Image from origin 'https://feazt-static.s3.amazonaws.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
当我再次重新加载页面时,图像正在正确加载。请帮助我。
我实施的代码:
$timeout(function() {
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
var img_obj = document.getElementById("img_file_"+index);
img_obj.addEventListener('load', function() {
canvas.width = this.width*2;
canvas.height = this.height*2;
context.drawImage(this, 0, 0, canvas.width, canvas.height);
this.setAttribute("src",canvas.toDataURL());
});
img_obj.setAttribute('crossOrigin', 'anonymous');
img_obj.setAttribute("src",arg);
}, 2000);
答案 0 :(得分:1)