自定义组件为什么不能获取ctx?
开发工具版本号:stable 1.06.2401020 操作系统:win10专业版本, 我在自定义组件中,wxml中定义了<view class="cvs"> <canvas id="mycanvasHome" canvas-id="mycanvasHome" type="2d" bindtouchstart="pantStart" bindtouchmove="pantMove" style="width: {{w_c}}px;height: {{h_c}}px;"> </canvas> </view> 在对应的js文件中,生命周期ready函数中获取ctx,代码如下:const query = wx.createSelectorQuery().select('#mycanvasHome').fields({node: true,size: true}).exec(function (res){ console.log('select_mycanvasHome') console.log(res) const canvas = res[0].node const context = canvas.getContext('2d') const renderW = res[0].width const renderH = res[0].height const dpr = wx.getWindowInfo().pixelRatio canvas.width = renderW * dpr canvas.height = renderH * dpr context.scale(dpr, dpr) this.setData({ ctx: context }) }) 在其他页面的json中也注册了自定义组件: "mystockLine": "../../component/stockLine/stockLine" 在其他页面的wxml中调用这个组件的代码如下:<mystockLine ></mystockLine> 在调试时报错如下: TypeError: Cannot read property 'node' of null at Object.<anonymous> (stockLine.js? [sm]:29) at Function.<anonymous> (WAServiceMainContext.js?t=wechat&s=1709696379677&v=3.3.4:1) at :21660/appservice/<SelectorQuery callback function> at WAServiceMainContext.js?t=wechat&s=1709696379677&v=3.3.4:1 at WAServiceMainContext.js?t=wechat&s=1709696379677&v=3.3.4:1 at Array.forEach (<anonymous>) at WAServiceMainContext.js?t=wechat&s=1709696379677&v=3.3.4:1 at WAServiceMainContext.js?t=wechat&s=1709696379677&v=3.3.4:1 at WASubContext.js?t=wechat&s=1709696379677&v=3.3.4:1 at ve (WASubContext.js?t=wechat&s=1709696379677&v=3.3.4:1)(env: Windows,mp,1.06.2401020; lib: 3.3.4) 请问是什么原因,调试了两天了,也没有解决,实在不知道总是出在哪了,用文心一言大模型也没有解决这个问题。 肯请微信团队高人指点一二,诚盼,万分感谢。