首页 > 解决方案 > 如何在即将响应的离子 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 )">

标签: angularionic2ionic3ionic-native

解决方案


推荐阅读