Closed gaoxing888 closed 1 year ago
请教一下这个怎么解决的 ?
其实是报错有问题,实际上可能是你的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();
})
}
请教一下这个怎么解决的 ?