CameraContext.takePhoto
解释:拍照,可指定质量,成功则返回图片。
方法参数
Object object
object参数说明
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
<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>
-
Page({data: {src: ''},onShow() {const cameraContext = swan.createCameraContext();this.cameraContext = cameraContext;},takePhoto() {this.cameraContext.takePhoto({quality: 'high',success: res => {this.setData({src: res.tempImagePath});}});}});
