在代码中加入
/** @type {HTMLCanvasElement} */ 即可拥有canvas全部代码提示
<script>
/** @type {HTMLCanvasElement} */
let cvs = document.getElementById('cvs')
let ctx = cvs.getContext('2d')
ctx.rect(300, 150, 200, 100)
ctx.lineWidth = 2
ctx.arc(100, 100, 90, 0, 2 * Math.PI)
ctx.stroke()
</script>