Ionic 2 - 拍照时不显示 Base 64 图像

Ionic 2 - Base 64 image not displayed when taking picture

这些让我摸不着头脑几个小时,现在快把我逼疯了。

当我点击 'Take Picture' 按钮时,相机会按预期打开,但返回的图像数据不会显示在应用程序中。

拍照HTML

<ion-item (click)="takePicture()">
  Take Picture
  <ion-icon item-right name="camera"></ion-icon>
</ion-item>

显示图片HTML

<img *ngFor="let image of images" [src]="'data:image/jpeg;base64,' + image">

拍照方式

images: string[] = [];

takePicture() {
  Camera.getPicture({
    quality: 50,
    destinationType: Camera.DestinationType.DATA_URL,
    targetWidth: 1000,
    targetHeight: 1000
  })
  .then(imageData => {
    this.images.push(imageData);
  });
}

应用程序出错

从 Ionic 论坛得到了答案,这对我有用。仍然不确定为什么我的代码不起作用...

src="data:image/jpeg;base64,{{image}}"