我已經嘗試了一些代碼,但它不能正常工作。如何設置循環的時間延遲,每當它執行時,在Javascript中
\t \t var canvas=document.getElementById('can');
\t \t ctx=canvas.getContext('2d');
\t \t canvas.width=1200;
\t \t canvas.height=750;
\t \t
\t \t for (var x = 100; x <=900; x+=10) {
\t \t \t \t linedraw(x);
\t \t }
\t \t function linedraw(n) {
\t \t \t setTimeout(function(){
\t \t \t \t ctx.moveTo(n,100);
\t \t \t \t ctx.lineTo(n+20,100); \t
\t \t \t \t ctx.stroke();
\t \t \t },1000 * 5);
\t \t }
<canvas id="can" style="background-color: gray"></canvas>
是完美的答案!!! ..其清晰,我需要做一個小的改變..謝謝你@Dummy –