CameraContext.takePhoto

解释:拍照,可指定质量,成功则返回图片。

方法参数

Object object

object参数说明

示例

在开发者工具中预览效果

扫码体验

请使用百度APP扫码

图片示例

代码示例

-

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

-

  1. Page({
  2. data: {
  3. src: ''
  4. },
  5. onShow() {
  6. const cameraContext = swan.createCameraContext();
  7. this.cameraContext = cameraContext;
  8. },
  9. takePhoto() {
  10. this.cameraContext.takePhoto({
  11. quality: 'high',
  12. success: res => {
  13. this.setData({
  14. src: res.tempImagePath
  15. });
  16. }
  17. });
  18. }
  19. });