<camera device-position="font" flash="off" style="width:100%;height:300px;" frame-size="small" bindinitdone="camera_frame_listener"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<image mode="widthFix" src="{{src}}"></image>
<text>{{text_data}}</text>
// camera.js
var listener;
Page({
onLoad(){
console.log("onLoad");
},
onReady(){
console.log("onReady");
var camera_ctx = wx.createCameraContext()
listener = camera_ctx.onCameraFrame((frame) => {
console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height)//该根本就不执行,找了很久不知道原因
})
listener.start()
console.log(listener);
},
data:{
text_data:""
},
camera_frame_listener(){
},
outlog(){
this.setData({
text_data:"aaaaa"
})
},
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
})
}
})
},
error(e) {
console.log(e.detail)
}
})
多插拔几次摄像头,就不回提示IDE不支持了。
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)