"Refused to load the image" 在 Chrome 应用中

"Refused to load the image" in a Chrome App

我在 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:".

应用cannot override the CSP。该清单密钥仅用于扩展。

See documentation 用于加载远程内容以供显示。

同样,您必须在 Chrome 应用程序中使用 <webview> 而不是 iframe。

这是我最后采用的解决方案:

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();