0
Follow
0
View

Html Canvas Click draw picture problem

dhxqh1002 注册会员
2023-02-27 11:35

the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > the cause of the problem is buttons[0].addEventListener("click",draw(context,image1.path,image1.xpos,image1.ypos,image1.height,image1.width)); The draw function in this line of code is actually executed immediately, rather than being called when the button is clicked. This is because the second argument passed to addEventListener should be a function, not the result of a function call.

To fix this, change this line of code to the following form:

buttons[0].addEventListener("click", function() {
  draw(context,image1.path,image1.xpos,image1.ypos,image1.height,image1.width);
});


This way, the draw function is not executed immediately when the code loads, but is called only when the button is clicked.

a251010547 注册会员
2023-02-27 11:35
,function(){ draw ( context , image1.path, image1.xpos, image1.ypos, image1. height , image1. width ) } ); .
< !- - - - - >

About the Author

Question Info

Publish Time
2023-02-27 11:35
Update Time
2023-02-27 11:35

Related Question

下一次构建不构建完整的html页面随需应变SSG

Angular 14的Typescript使用HTML中的url属性加载JSON

对html选择框进行排序,但忽略选择

为什么我的转换Markdown HTML标签作为文本返回?

网页底部效果html

Angular13 Storybook设置模板为html导入

用html发送ajax请求浏览器端报错

在bash中替换html中的图像src标签

在web项目中获取页面完全运行后的html

Applescript Mouse Click Reference absolute or relative