【发布时间】:2021-09-09 04:38:27
【问题描述】:
我正在开发一个移动应用程序,我想打开图库以选择图片,但是当单击按钮时应用程序没有任何反应,甚至没有抛出错误,这是我的代码:
photos: any = '';
base64Image = '';
async agregarImg() {
const actionSheet = await this.actionSheetController.create({
header: 'Seleccionar medio',
buttons: [{
text: 'Cámara',
icon: 'camera',
handler: () => {
this.takePicture(CameraSource.Camera, false)
}
}, {
text: 'Galería',
icon: !this.platform.is('ios') ? 'ios-images-outline' : 'images-outline',
handler: () => {
this.openGallery();
}
}]
});
await actionSheet.present();
}
openGallery() {
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.DATA_URL,
mediaType: this.camera.MediaType.PICTURE,
encodingType: this.camera.EncodingType.JPEG,
correctOrientation: true,
allowEdit: false,
}
this.camera.getPicture(options).then((imageData) => {
this.base64Image = 'data:image/jpeg;base64,' + imageData;
this.photos.push(this.base64Image);
this.photos.reverse();
}, (err) => {
console.log(err);
})
}
我读到了这个问题,可能插件会发生这种情况,这在 Android 上不能完美运行。 我使用这个插件: import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
【问题讨论】:
-
您是否将 console.log 语句放入您的代码中以查看它在哪里发生故障?
标签: angular typescript ionic-framework