gpt4 book ai didi

image - ionic 2 + Angular 2 : Images prepended with 'unsafe:' therefore not displaying even though they're fine

转载 作者:太空狗 更新时间:2023-10-29 16:50:49 26 4
gpt4 key购买 nike

出于某种原因,我的某些图像被添加了 'unsafe:' 前缀,这导致它们无法呈现。

问)为什么会发生这种情况,我该如何解决 - Angular 2 是否与白名单或 Ionic 2 不一致?

例如

<p><img src="unsafe:data:image/jpeg;base64,/9.....
<p><img src="data:image/jpeg;base64,/9.....

图片没有问题(看这里),看plunkr here

第二张图片是从 Ionic 2 渲染的,第一张图片我手动删除了前缀以显示它没问题。

最佳答案

对于遇到此问题的任何人,我已经使用以下方法“解决”了它:

类:

import {DomSanitizationService} from '@angular/platform-browser';

constructor(private _DomSanitizationService: DomSanitizationService) {}

模板:

<img [src]="_DomSanitizationService.bypassSecurityTrustUrl(imgSrcProperty)"/>

其中 imgSrcProperty 是有问题的 base64 编码图像。

我仍然认为这是一个错误!

关于image - ionic 2 + Angular 2 : Images prepended with 'unsafe:' therefore not displaying even though they're fine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38080654/

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