CameraContext.takePhoto

解释:拍照,可指定质量,成功则返回图片。
Web 态说明:Web 态暂不支持 CameraContext 相关方法,在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

方法参数

Object object

object参数说明

参数名类型必填默认值说明

quality

String

normal

成像质量,有效值为 high, normal, low

success

Function

接口调用成功的回调函数,res = { tempImagePath }

fail

Function

接口调用失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

百度智能小程序

请使用百度APP扫码

图片示例

CameraContext.takePhoto - 图2

代码示例

  • SWAN
  • JS
  1. <div class="camera">
  2. <camera device-position="{{device}}" flash="off" binderror="error" style="width: 100%; height: 500rpx;"></camera>
  3. <button type="primary" bind:tap="takePhoto">拍照</button>
  4. <image class="img" mode="widthFix" src="{{src}}"></image>
  5. </div>