小潭
2015-10-20 08:54
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>canvas</title> </head> <body> <canvas id="canvas" style="display:block;margin:10px auto; border:1px solid #aaa;"></canvas> <script> window.onload = function() { var canvas=document.getElementById('canvas'); var context=canvas.getContext('2d'); canvas.weight = 1000; canvas.height = 300; context.beginPath(); context.moveTo(20,20); context.lineTo(200,100); context.closePath(); context.lineWidth=5; context.stroke(); } </script> </body> </html>
您写错了~
你好,这里的宽度应该是“width”,而不是“weight”,改过来就可以了。
炫丽的倒计时效果Canvas绘图与动画基础
96746 学习 · 1000 问题
相似问题