多插拔几次摄像头,就不回提示IDE不支持了。
onCameraFrame不执行监听函数?<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) } })
2019-10-29