data: {
imgPath:’’,
operate:‘拍照’
},
takephoto: function () {
var that = this
if (wx.createCameraContext()) {
const ctx = wx.createCameraContext(“myCamera”)
ctx.takePhoto({
quality: ‘normal’,
success: function (res) {
that.setData({
imgPath: res.tempImagePath,
})
}
})
} else {
wx.showModal({
title: ‘提示’,
content: ‘当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。’
})
}
},
error:function(e) {
console.log(e.detail)
},
<view>
<camera id=“myCamera” device-position=“front” flash=“auto” binderror=“error” class=‘camera’></camera>
<image src="{{imgPath}}" class=“img”></image>
</view>