Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开发者工具报错小程序不支持动态创建组件, 线上安卓机会报WebGLCanvasContext2d的错 使用的是taro框架 #32

Closed
gaoxing888 opened this issue Oct 20, 2021 · 2 comments

Comments

@gaoxing888
Copy link

No description provided.

@lqliqi
Copy link

lqliqi commented Jun 8, 2023

请教一下这个怎么解决的 ?

@vickyleu
Copy link

请教一下这个怎么解决的 ?

其实是报错有问题,实际上可能是你的context为null

export interface CanvasNode {
    getContext(type: '2d'): CanvasRenderingContext2D;

    width: number;
    height: number;
    _left: number;
    _top: number;
    // ... 其他方法和属性
}

export function canvasNode(canvasTag: string): Promise<CanvasNode> {
    return new Promise((resolve, reject) => {
        Taro.createSelectorQuery().select(canvasTag).node((ref) => {
            if (ref) {
                const canvas = ((ref as unknown as unknown[]).length > 0) ? ref[0].node : ref.node;
                if (canvas) {
                    console.log(`typeof canvas==>${Object.getPrototypeOf(canvas)}`)
                    resolve(canvas);
                } else {
                    reject(ref);
                }
            }
        }).exec();
    })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants