论坛
标题:
问题
[打印本页]
作者:
L1587997
时间:
2019-10-22 18:50
标题:
问题
为什么我打的代码跟老师一样而且没有出错,但是页面的矩形我显示不出来[attach]152129[/attach]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>canvas</title>
<style>
body{ background: #ccc;}
#cvs{ background: #fff;}
</style>
<script>
window.onload=function(){
var c=document.getElementById("cvs");
var ctx=c.getContext("2d");
/*
ctx.fillStyle="red";
ctx.fillRect(50,50,100,100);
ctx.strokeStyle="yellow"
ctx.strokeRect(100,100,150,150);
*/
ctx.fillStyle="red";
ctx.strokeStyle="green"
ctx.rect(50,50,100,100);
ctx.fill();
ctx.stroke();
ctx.clearRect(0,0,c.width,c.height);
}
</script>
</head>
<body>
<canvas id="cvs" width="400" height="400"></canvas>
</body>
</html>
欢迎光临 论坛 (http://bbs.qinxue.com/)
Powered by Discuz! X3.1