【问题标题】:Display array of base64 image data as images将 base64 图像数据数组显示为图像
【发布时间】:2019-01-30 17:04:04
【问题描述】:

我正在输出项目的 RadListView,每个项目都有一个 base64 格式的图像,但我无法显示它们。

在组件循环中我有

let base64ImageSource = new ImageSource;
base64ImageSource = fromBase64(returned_expenses[i].receipt_data);

在模板中我有

<Image row="0" col="1" [src]="base64ImageSource" horizontalAlignment="right" width="100" height="100"  stretch="none"></Image>

而且没有图像。

我看过下面的代码

this.imageSource = new ImageSource();
var loadedBase64 = this.imageSource.loadFromBase64(MY_BASE_64_STRING_PREVIOUSLY_SAVED);
console.log(loadedBase64);
if (loadedBase64) {
  let photo = <Image>this.photoImage.nativeElement;
  photo.imageSource = this.imageSource;
  this.photo = photo;
}

但我不知道这条线是什么

let photo = <Image>this.photoImage.nativeElement;

即。 photoImage 声明为什么?

感谢您的指导!

【问题讨论】:

    标签: angular nativescript angular2-nativescript


    【解决方案1】:

    在您的示例代码中photoImage 可能是对元素的引用,可能正在使用ViewChild

    HTML

    ....
    <Image #photoImage></Image>
    ...
    

    TS

    @ViewChild("photoImage") photoImage: ElementRef;
    

    【讨论】:

      猜你喜欢
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      • 2011-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      相关资源
      最近更新 更多