真机调用摄像头自动弹出图片选择画面
发布于 6 年前 作者 jzhao 11286 次浏览 来自 问答
  • 当前 Bug 的表现

使用camera组件调用摄像头时自动弹出图片选择画面

  • 预期表现

直接进行拍摄

  • 复现路径

<camera device-position=“back” flash=“off” binderror=“error”></camera>

  • 提供一个最简复现 Demo
1 回复
<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<view>预览</view>
<image mode="widthFix" src="{{src}}"></image>
Page({
  takePhoto() {
    const ctx = wx.createCameraContext()
    ctx.takePhoto({
      quality: 'high',
      success: (res) => {
        this.setData({
          src: res.tempImagePath
        })
      }
    })
  },
  error(e) {
    console.log(e.detail)
  }
})
回到顶部