gpt4 book ai didi

dart - Chrome 应用程序中的 "Refused to load the image"

转载 作者:行者123 更新时间:2023-12-02 00:38:15 28 4
gpt4 key购买 nike

我在 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com