收藏
回答

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-18
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签