收藏
回答

canvas在使用时找不到节点?

<view class="containerstyle="width: 100%; height: 100vh;">

  <canvas canvas-id="mycanvasstyle="width: 100%; height: 100%;"></canvas>

  <button bindtap="takeScreenshot">截屏并上传</button>

</view>


wx.createSelectorQuery().select('#mycanvas').fields({ node: true, size: true }).exec((res) => {

      console.log('SelectorQuery 返回结果:', res);

      if (!res[0]) {

        console.error('未找到 canvas 元素');

        return;

      }

控制台打印结果:SelectorQuery 返回结果: [null]

contact.js? [sm]:19 未找到 canvas 元素

回答关注问题邀请回答
收藏
登录 后发表内容