当事件被触发时,图像不打印

我想在mousedown被解雇时绘制图像,但是我不能。当事件被触发时,图像不打印

我该怎么解决?

var brush = new Image();  

brush.src = "/wp-content/uploads/new2022/20220327voicc/207154258.png"

brush.onload = function(){

$("<canvas></canvas>").appendTo("body");

\t var canvas = $('canvas');

\t var context = canvas[0].getContext('2d');

\t canvas.width(500).height(300); \t

\t $('canvas').mousedown(function(event){

alert('canvas clicked on coordinates ('+event.pageX+','+event.pageY+')');

\t contex.drawImage(brush, event.pageX, event.pageY); \t

\t })

}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  

<body>

</body>

回答:

您输入了错误的单词 “背景”:

contex.drawImage(brush, event.pageX, event.pageY); 

应该

context.drawImage(brush, event.pageX, event.pageY); 

以上是 当事件被触发时,图像不打印 的全部内容, 来源链接: utcz.com/qa/257536.html

回到顶部