首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >浏览器中的ionic 5相机插件不显示拍照选项

浏览器中的ionic 5相机插件不显示拍照选项
EN

Stack Overflow用户
提问于 2021-02-08 12:37:18
回答 1查看 154关注 0票数 0

我在浏览器中使用ionic5 angular和相机插件。相机在前置相机打开的情况下启动,但我看不到捕捉照片的控件。代码如下所示

代码语言:javascript
复制
getFromCamera(){
    // alert('click');
  this.camera.getPicture({
        destinationType: this.camera.DestinationType.FILE_URI,
        quality: 25,
        correctOrientation: true,
          allowEdit:false
    }).then((imageData) => {
      console.log("got image from camera and setting it up with imageData:", imageData)
    }, (err) => {
        console.log(err);
        alert(err);
    });
}
EN

回答 1

Stack Overflow用户

发布于 2021-02-08 13:39:01

尝试使用相机选项,如下所示:

代码语言:javascript
复制
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';


const options: CameraOptions = {
  quality: 100,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE
}

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;
}, (err) => {
 // Handle error
});
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66095978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档