<! -- camera.wxml --><camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<button type="primary" bindtap="takePhoto">Taking pictures</button>
<view>preview</view>
<image mode="widthFix" src="{{src}}"></image>
Copy the code
// camera.js
Page({
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high'.success: (res) = > {
this.setData({
src: res.tempImagePath
})
}
})
},
error(e) {
console.log(e.detail)
}
})
Copy the code