美文网首页
关于vscode设置Canvas智能提示的采坑记录

关于vscode设置Canvas智能提示的采坑记录

作者: 不负好时光_9c46 | 来源:发表于2020-10-30 15:23 被阅读0次

我在vscode中的插件市场将canvas的插件安装了个遍也没有提示效果。

网上找到的解决方案都是添加 /** @type {HTMLCanvasElement} */。这段代码很有效,但是一定要注意放置的位置。

一开始我将这段代码拷贝到js最前面怎么都不起作用。

请一定要将这段代码拷贝到获取canvas元素的上面,即document.getElementById("canvas")前面

无效设置:

/** @type {HTMLCanvasElement} */    

window.addEventListener('load', eventWindowLoad, false);  

 var theCanvas = document.getElementById('canvasOne');   

 var context = theCanvas.getContext('2d');

正确设置:

window.addEventListener('load', eventWindowLoad, false);   

 /** @type {HTMLCanvasElement} */   

 var theCanvas = document.getElementById('canvasOne');   

var context = theCanvas.getContext('2d');

相关文章

网友评论

      本文标题:关于vscode设置Canvas智能提示的采坑记录

      本文链接:https://www.haomeiwen.com/subject/frrdvktx.html