為什么不顯示第一條線
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>測試</title>
</head>
<body>
<canvas id="canvas" width = 1024 height = 768 style="border:1px solid #aaa;display:block;margin:50px auto;"></canvas>
? ?
? ?<script>
? ? ? window.onload = function(){
? ? ? ? ?var canvas = document.getElementById("canvas");
? ? ? ? ?
? ? ? ? ?canvas.width = 1024;
? ? ? ? ?canvas.height = 768;
? ? ? ? ?
? ? ? ? ?var context = canvas,getconText("2d")
? ? ? ? ?//使用context繪制
? ? ? ? ?context.moveTo(100,100)
? ? ? ? ?context.lineTo(700,700)
? ? ? ? ?context.stroke()
? ? ? }
? ?</script>
</body>
</html>
2016-08-24
var context = canvas,getconText("2d")
改為:
var context = canvas.getConText("2d")