关于canvas的一个小问题
请问各位大神,我下面的代码为什么不能画出矩形<!DOCTYPEhtml><html><headlang="en"><metacharset="UTF-8"><title>...
请问各位大神,我下面的代码为什么不能画出矩形
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
window.onload= function () {
document.body.style.backgroundColor="#eee"
document.body.style.transition="all 2s"
var can=document.getElementById("can")
var cxt=can.getContext("2d")
var width=window.innerWidth;
var height=window.innerHeight;
cxt.fillRect(width/2,height/2,100,100)
}
</script>
</head>
<body bgcolor="black">
<canvas id="can"></canvas>
</body>
</html> 展开
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
window.onload= function () {
document.body.style.backgroundColor="#eee"
document.body.style.transition="all 2s"
var can=document.getElementById("can")
var cxt=can.getContext("2d")
var width=window.innerWidth;
var height=window.innerHeight;
cxt.fillRect(width/2,height/2,100,100)
}
</script>
</head>
<body bgcolor="black">
<canvas id="can"></canvas>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询