代码如下:
预览没问题,真机调试不行。真机调试时exec()里面的回调函数没执行。
预览的时候,console.log三个都能打出来。真机调试真能打出来1和2这两个。
let canvas,selector
onReady: function () {
console.log(“1—ready1”)
selector = wx.createSelectorQuery()
console.log(selector.select(’#webgl’).node())
selector.select(’#webgl’).node().exec((res) => {
canvas = res[0].node
console.log(“3—ready3”)
})
this.ctx = wx.createCameraContext()
console.log(“2—ready2”)
<!-- index.wxml -->
<canvas type=“webgl” id=“webgl” canvas-id=“webgl” style=“width: 100%; height: 300px;”></canvas>
<camera device-position=“back” flash=“off” binderror=“error” style=“width: 100%; height: 300px;”></camera>