【发布时间】:2018-06-05 14:32:33
【问题描述】:
我想为个人资料图片显示 base64 图像。 图像作为二进制数据存储在数据库中,我使用 btoa() 将此二进制数据转换为 base64。现在我想将此base64图像绑定到img src 我尝试了很多方法,但它不起作用,请帮助 这是我的代码
profile.ts 代码:
profilePicture(binImage)
{
if(binImage != null)
{
var imageData = btoa(binImage);
//console.log("Base64 Image: ",imageData);
this.displayImage = imageData;
}
}
profile.html 代码:
<div class="profile-picture big-profile-picture" *ngIf="displayImage">
<img src="data:Image/*;base64,{{displayImage}}">
</div>
显示错误“清理不安全的 url 值 safevalue 必须使用 [property]=binding”
【问题讨论】:
-
控制台有错误吗?
-
是的。错误:“清理不安全的 URL 值”
标签: angular image ionic-framework base64 ionic3