为什么我用canvas画不出那条线
为什么我的context.lineTo(700,700),画不出来那条线。
为什么我的context.lineTo(700,700),画不出来那条线。
2016-12-12
<!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: 20px auto;"><!-- 默认宽300像素,高150像素 -->
当前浏览器不支持canvas,请切换浏览器后再试;
</canvas>
<script type="text/javascript">
window.onload=function(){
var canvas=document.getElementById('canvas');
var context=canvas.getContext("2d");
canvas.width=1024;
canvas.height=768;
context.moveTo(100,100);
context.lineTo(700,700);
context.lineWidth=5px;
context.strokeStyle="#005588";
context.stroke();
}
</script>
</body>
</html>
到底错哪了,没显示啊,就一个框
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas01</title>
</head>
<body>
<canvas id="canvas" style="border:1px solid #aaa;display:block;margin:50px auto;">
当前浏览器不支持canvas,请更换更高级的浏览器,如谷歌、火狐等。
</canvas>
<script>
widow.onload = function(){
var canvas = document.getElementById("canvas");
canvas.width = 1024;
canvas.height = 650;
var context = canvas.getContext("2d");//使用context绘制
context.moveTo(100,100);
context.lineTo(300,300);
context.strokeStyle="#005588";
context.stroke();
}
</script>
</body>
</html>
同样没有画出线 哪里的问题啊 晕死了
举报