“拒绝加载图像”在Chrome应用程式中 [英] "Refused to load the image" in a Chrome App
问题描述
我在dart中遇到这个问题
I have this problem in dart
拒绝载入图片https://**.png
遵循Content Security Policy指令:img-src'self'data:
chrome-extension-resource:。
Refused to load the image 'https://**.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:".
$ b b
尝试在image元素中设置src
when try to set src in image element
ImageButtonInputElement button = new ImageButtonInputElement();
button.className="button_element";
button.src=el["imageUrl"]; //like "https://**.png"
whit this manifest.json
whit this manifest.json
"content_security_policy":"img-src https://server.example.org"
有人知道会帮助我吗?
Someone would know help me?
感谢
对不起,我的英文不好。
Sorry for my bad English
EDIT
我对
<iframe id="iframe" src="https://server.example.org/example.html"></iframe>
拒绝框架
https://server.example.org/example.html
,因为它违反了以下内容安全策略指令:
frame-src'self'data:chrome-extension-resource:。
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:".
推荐答案
这是我最终采用的解决方案:
This is the solution I have adopted in the end:
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();
这篇关于“拒绝加载图像”在Chrome应用程式中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!