怎样让微信小程序在拍照时可以选择打开闪光灯,请教一下,在如下图中在哪里添加
文档
https://developers.weixin.qq.com/miniprogram/dev/component/camera.html
代码
https://developers.weixin.qq.com/s/bzoEN9md7cDG
index.wxml
<view class="intro">欢迎使用代码片段,可在控制台查看代码片段的说明和文档</view>
<camera device-position="back" flash="{{isFlash? 'on' : 'off'}}" binderror="error" style="width: 100%; height: 300px;"></camera>
<switch checked="{{isFlash}}" bindchange="flashChange" /> 开启闪光灯
<button type="primary" bindtap="takePhoto">拍照</button>
<view>预览</view>
<image mode="widthFix" src="{{src}}"></image>
index.js
Page({
data: {
isFlash: false
},
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
})
}
})
},
flashChange(e) {
console.log(e);
this.setData({ isFlash: e.detail.value })
},
error(e) {
console.log(e.detail)
}
})
应该不行吧 。如果api没有这个 属性 那就不行 。我看了一下 朋友圈的 调用相机 根本没有 闪光灯操作。就一个 拍摄按钮 。你调用相机 用的是哪个 api?