首页 > 解决方案 > 离子电容器:如何从相机选项中限制图库?

问题描述

对于我正在构建的应用程序,我正在使用 Capacitor 的相机插件。当我单击启动相机的按钮时,它要求我首先在图库和相机之间进行选择。

我想关闭“从图库中挑选”功能。有什么解决办法吗?

在此处输入图像描述

标签: ionic-frameworkcapacitor

解决方案


默认情况下,相机插件会提示,但您可以通过传递源属性来选择相机或画廊

// The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. Default: CameraSource.Prompt
source ?: CameraSource;

完整示例:

const image = await Camera.getPhoto({
    quality: 90,
    resultType: CameraResultType.Uri,
    source: CameraSource.Camera
});

推荐阅读