画布线无法正常工作 IOS / IPAD



嘿,我用画布画了一个简单的点

ctx.lineWidth = 5;
ctx.lineJoin = 'round';
ctx.lineCap = 'round';
ctx.strokeStyle = 'blue';
ctx.beginPath();
//ctx.moveTo(last_mouse.x, last_mouse.y);
ctx.lineTo(120, 40);

但它在IOS上不显示点,仅在Android/Windows上显示

您的代码在任何浏览器上都没有为我绘制任何内容......

我在最后添加了一个适当的 moveTo 和一个笔画,这是示例:

<canvas id="canvas" style="border:1px solid #000000;"></canvas>
<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.lineJoin = ctx.lineCap = 'round';
// Draw a Blue dot on the middle of the canvas
ctx.beginPath();
ctx.lineWidth = 50;
ctx.strokeStyle = 'blue';
ctx.lineTo(canvas.width / 2, canvas.height / 2);
ctx.stroke();
// Draw a diagonal Red line on the canvas
ctx.beginPath();
ctx.lineWidth = 5;
ctx.strokeStyle = 'red';
ctx.moveTo(20, 20);
ctx.lineTo(canvas.width - 20, canvas.height - 20);
ctx.stroke();
</script>