小程序拍照功能

<camera device-position="back" flash="off" binderror="error" style=" 100%; height: 300px;"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<view>预览</view>
<image mode="widthFix" src="{{src}}"></image>
 
 

takePhoto() {
  const ctx = wx.createCameraContext()
  ctx.takePhoto({
    quality: 'high',
    success: (res) => {
      this.setData({
        src: res.tempImagePath
      })
    }
  })
},
原文地址:https://www.cnblogs.com/shuihanxiao/p/15041855.html