我在 dart 中遇到这个问题
Refused to load the image 'https://**.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:".
当尝试在图像元素中设置 src 时
ImageButtonInputElement button = new ImageButtonInputElement();
button.className="button_element";
button.src=el["imageUrl"]; //like "https://**.png"
这个manifest.json
"content_security_policy":"img-src https://server.example.org"
有人知道可以帮帮我吗?
谢谢
抱歉我的英语不好
编辑
我也有同样的问题
<iframe id="iframe" src="https://server.example.org/example.html"></iframe>
Refused to frame https://server.example.org/example.html because it violates the following Content Security Policy directive: "frame-src 'self' data: chrome-extension-resource:".
最佳答案
这是我最终采用的解决方案:
var imgRequest = new HttpRequest();
imgRequest.open('GET', url);
imgRequest.responseType = 'blob';
imgRequest.onReadyStateChange.listen((var request){
if (imgRequest.readyState == HttpRequest.DONE &&
imgRequest.status == 200) {
FileReader reader = new FileReader();
reader.onLoad.listen((fe) {
button.src = reader.result;
});
reader.readAsDataUrl(imgRequest.response);
}
});
imgRequest.send();
关于dart - Chrome 应用程序中的 "Refused to load the image",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30544033/