解决方法:
- 如果是2d上下文,则在获取上下文的前一句加上/** @type {CanvasRenderingContext2D} */
- 如果是3d上下文,则加上/** @type {WebGLRenderingContext} */
let drawing = document.querySelector("#canvas")
if (drawing.getContext) {
/** @type {CanvasRenderingContext2D} */
let context = drawing.getContext("2d")
标签:canvas,vscode,js,getContext,上下文,type,drawing
From: https://www.cnblogs.com/hexrui/p/17834211.html