cordova-plugins - Ionic4 相机插件-cordova 在设备上不可用?
问题描述
我正在开发一个需要能够拍照的 Ionic4 应用程序。我添加了“cordova-plugin-camera”。当我在真实设备上运行此插件的功能拍照时,我收到错误“cordova_not_avaliable”。(请注意,其他本机 cordova 插件工作得很好- 即使在同一页面/模块中)。
我遵循了“cordova-plugin-camera”的 Ionic 文档的基本安装过程。不会引发其他错误。
import { Component, OnInit } from '@angular/core';
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
@Component({
selector: 'app-picture',
templateUrl: './picture.page.html',
styleUrls: ['./picture.page.scss'],
})
export class PicturePage implements OnInit {
options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
constructor(private camera: Camera) { }
ngOnInit() {}
takePicture() {
this.camera.getPicture(this.options).then((imageData) => {
let base64Image = 'data:image/jpeg;base64,' + imageData;
// this.presentAlert('success');
}, (err) => {
// this.presentAlert(err); // Displays "cordova_not_avaliable"
// (For show on DEVICE. I know rest logic of alert is missing)
});
}
}
我希望科尔多瓦是可用的,因为它在安卓设备上运行。不存在其他错误(另请注意,我在离子服务上得到完全相同的结果)。
编辑:“还要注意我在这种环境中还不是很有经验,所以我可能会遗漏一些明显的东西。”
编辑:“标题(删除预览)”
解决方案
找到解决方案,在我的相机选项中,我错过了
sourceType: this.camera.PictureSourceType.CAMERA
这解决了问题。
推荐阅读
- batch-file - 你能模拟从批处理文件中点击进入吗?
- r - 将函数应用于列的可变子集
- css - CSS nth-child:nth-child(1n) 究竟选择了什么
- angular - 无法使用 Angular 中 Rxjs 库的过滤器、映射或跳过运算符跳过每一行中的第一个数据值
- google-drive-shared-drive - 在 Google Workspace 共享云端硬盘中查找与外部用户共享的文件和文件夹
- angular - Rxjs 等待操作符
- raspberry-pi - 我的 mariadb-10.3 版本出错
- jdbc - Variant 列不支持批处理数组绑定
- flutter - 如何使用 ListView 构建器在一行中显示 CheckboxListTile 文本?
- oracle - 如何从文本文件将数据加载到 oracle 表并使用 shell 脚本检查记录是否已存在?