我的不出來(lái)直線,檢查沒(méi)問(wèn)題啊,求指教!著急啊、、、
<!DOCTYPE html >
<html>
<head>
<meta ?charset=utf-8 >
<title>無(wú)標(biāo)題文檔</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");
? var context=canvas.getContext("2d")
??
? context.moveTo(100,100)
? context.lineTo(700,700)
? context.lineWidth=5
? context.strokeStyle="#005588"
? context.stroke()
? }
?</script>
</body>
</html>
2014-12-08
順便說(shuō)一下,你的js代碼既然都放在body下面了,window.onload 是多此一舉哦,可以去掉window.onload = function(){} ?直接寫里面的代碼。
2014-12-08