node.js - B64图像不以 Angular 显示

标签 node.js angular

我想以 Angular 显示 B64 图像字符串。当我放置静态图像字符串时,它会显示,但是当图像是动态时,它会显示一些问题 下面是我的 component.ts 代码

      this.Socket_io = socketIo('http://192.168.0.109:3011');
      this.Socket_io.on('echo', (obj) => {

      var a = JSON.parse(obj)

      this.img = a.image_path;

      this.image_path = this.sanitizer.bypassSecurityTrustResourceUrl('data:image/jpg;base64,'  
      + this.img); 

下面是我的html

     <img [src]="image_path">

Image string is being shown in html but it is not displayed

B64 string coming as

最佳答案

尝试这样

<img [src]="image_path">

这里是 stackblitz https://stackblitz.com/edit/angular-view-image?file=src/app/app.component.html

关于node.js - B64图像不以 Angular 显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58967838/

相关文章:

node.js - 设置 connect-flash 中间件以供 passport 使用

node.js - Amazon Kinesis NodeJS - putRecord 操作过期

javascript - 在 "Pro Javascript for Web Dev"书中找不到 server.js

angular - 使用 Angular react 形式进行信用卡验证

angular - 错误 : Cannot match any routes. URL 段: Angular 7 中的 ''

javascript - 在 Mongoose 中使用 "Ref"获取 mongo 数据时出现问题

javascript - 如何模拟 readline.on ('SIGINT' )?

javascript - 当我运行应用程序时,哪个文件首先在 angular 4 应用程序中运行?

javascript - NgIf 里面点击 Angular

angular - 与应用程序组件中的包进行通信的正确方法是什么?