【发布时间】:2020-02-11 07:36:40
【问题描述】:
我在显示 base64 图像时遇到问题。
当我以 base64 格式从相机上传图像时,我可以通过 ionic devapp 显示它,但是当我从 Xcode 构建它并在我的 ios 设备上本地运行它时,图像显示为损坏的图像。
有人解释一下吗?
谢谢!
private choosePicture() {
const options = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: 0,
correctOrientation: true
};
this.camera.getPicture(options).then((imagePath) => {
let base64Image = 'data:image/jpeg;base64,' + imagePath;
let images = this.createClass.get('imagePath') as FormArray;
images.push(new FormControl(base64Image));
}, (err) => {
if(err !== 'no image selected') {
this.logError(err);
}
});
}
还有我的html
<ion-col col-6 col-md-4 col-xl-3 *ngFor="let image of createClass.controls['imagePath'].value; let i = index">
<img src="{{ image }}"/>
</ion-col>
【问题讨论】:
标签: ios typescript ionic-framework base64