是的,我只是想知道,为什么我不能用触摸在画布上画一个正方形?我究竟做错了什么?请,任何帮助将不胜感激:)
这是代码:
JAVASCRIPT:
// "Square" Button
function square()
{
var can = document.getElementById('canvasSignature');
var ctx = can.getContext('2d');
can.addEventListener( 'touchstart', onTouchStart, false);
function onTouchStart(e) {
ctx.fillRect(0,0,300,300);
}
}
HTML5:
<div id="canvasDiv">
<canvas id="canvasSignature" width="580px" height="788px" style="border:2px solid #000; background: #FFF;"></canvas>
</div>
<div id="Square">
<p><button onclick="square();">Square</button></p>
</div>