为什么我打的代码跟老师一样而且没有出错,但是页面的矩形我显示不出来
<!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>
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|
 点赞26 哪些同学觉得很赞!
lori棒棒糖 觉得很赞
昵昵妹 觉得很赞
潜意式 觉得很赞
龙猫1212 觉得很赞
大大大表哥 觉得很赞
依仔101 觉得很赞
西卡 觉得很赞
一品数码 觉得很赞
热爱生活热爱家 觉得很赞
我叫大帅比 觉得很赞
|
|
|