uniapp在mounted内这么使用uni.createSelectorQuert()报错,请问如何解决?

出现这个错误的原因是在其它的页面也使用了这个api,但是页面并未渲染,导致报错。
image.png
image.pngimage.png

阅读 2k
1 个回答

试一下直接在后面.select,去掉query.selsect

         return new Promise((resolve) => {
                wx.createSelectorQuery()
                    .in(this)
                    .select('#van-circle')
                    .node()
                    .exec((res) => {
                    const canvas = res[0].node;
                    const ctx = canvas.getContext(type);
                    if (!this.inited) {
                        this.inited = true;
                        canvas.width = size * dpr;
                        canvas.height = size * dpr;
                        ctx.scale(dpr, dpr);
                    }
                    resolve(adaptor(ctx));
                });
            });
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题