我正在执行以下代码,但是在我的设备上,我可以看到损坏的图像而没有任何信息(甚至稍等片刻即可加载图像...),这是我的代码:
TypeScript
FindAll()
HTML
goPhotoGallery() {
const options: CameraOptions = {
quality: 80,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation: true,
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
let base64Image = 'data:image/jpeg;base64,' + imageData;
this.images = base64Image;
}, (err) => {
// Handle error
});
我该怎么做才能正确显示图像?
答案 0 :(得分:1)
终于解决了:
destinationType: this.camera.DestinationType.DATA_URL,
代替
destinationType: this.camera.DestinationType.FILE_URI,
结局
答案 1 :(得分:0)
使用括号{{images}}
<ion-content padding>
<ion-card>
<img src="{{ images }}" />
</ion-card>
</ion-content>