< canvas type = "webgl" id = "c" ></ canvas > |
wx.createSelectorQuery() .select( '#c' ) .node() .exec((res) => { let canvasId = res[0].node._canvasId console.log(canvasId) }) |
在工具中,这个api回调可以正常,但是到真机上则无法正常执行
当type ='2d'时 微信版本7.0.4 时上面代码片段的exec回调不执行,
我也遇到相同问题
wxml <canvas id="rafCanvas" type="2d" style="display:none;"></canvas> ts onLoad(options) { const eventChannel = this.getOpenerEventChannel(); // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 eventChannel.on('acceptDataFromOpenerPage', (data: { path: string; size: number }) => { // 通过 SelectorQuery 获取 Canvas 节点 wx.createSelectorQuery() .select('#rafCanvas') .fields({ node: true, }) .exec(res => { canvas = res[0].node; wx.getSystemInfo({ success: res => { this.setData({ windowHeight: res.windowHeight, windowWidth: res.windowWidth, pixelRatio: res.pixelRatio, }); this.analysis(data); }, fail: err => { console.log(err); }, }); }); }); },
指的是这个真机调试是么?预览正常是么?