angular - 如何在即将响应的离子 3 中显示图像?
问题描述
我正在尝试在来自 Rest API 的 Ionic 3 中显示图像。我正在使用一个名为的库angular/platform-browser
;
import {DomSanitizer} from '@angular/platform-browser';
let url = 'http://10.75.0.101/port_3480/data_request?id=cam_image&Device_Num=103'
this.httpNative.get(url, {}, {}).then((res:HTTPResponse) => {
console.log(JSON.stringify(res))
this.images=res.data;
this.showPage = "data:image/jpeg;base64," + this.images;
alert(this.showPage );
}).catch(err=>{
console.log("error:"+JSON.stringify(err))
})
}).catch((e) => {
console.log(e)
});
HTML 代码。
<img [src]="_DomSanitizationService.bypassSecurityTrustUrl(showPage )">
解决方案
推荐阅读
- python - 在 Jupyter Notebook 中导入 matplotlib 时找不到子包
- apache-kafka - 使用 Kafka 的一对一和群组消息传递
- kubernetes - k8s 作业已完成,但 pod 显示“OOMKILLED”
- c - 如何将int数组转换为bin int?
- discord.js - 如何为我的 discord.js 机器人读取文本文件中的行数?
- java - 关闭执行器服务
- django - Filter by calculated field dependent on foreign key
- amazon-web-services - 什么metdata ecs-tasks.amazonaws.com 提供给sts 服务来承担角色?所以,我们可以为此设置条件
- c++ - 如何在不使用 getline() 的情况下接受不同行中的整数输入值?
- android - 我怎样才能拥有一项菜单 rtl 和另一项 ltr?