The project uses pug and needs to generate a canvas tag, so the following code is added
canvas(class='work-item_background_canvas')
But after using js to obtain this object, calling getContext('2d') returns null
When the object is printed out, it is <canvas class="work-item_background_canvas">
Please tell me where it comes from Got a problem?
With a template engine like this, you first have to make sure whether it generated what you really want
HTML ELEMENT
,模版引擎最终都是生成html
的,确定真的有这个dom
,那就一定是js
运行时的api
or if there is something wrong.The question is not clear to me, but I should check with
pug
的关系不大,检查一下canvas
相关的api
whether there is any problem with the call.