我刚刚开始学习如何使用 HTML5 画布进行绘图,我正在尝试制作一个简单的正方形,但我得到的只是一个空白屏幕,我在 chrome 控制台中也没有出现错误
<!Doctype html>
<html>
<head>
<title>Drawing to a canvas</title>
<script type="text/javascript" language="javascript" >
window.onload = draw;
function draw()
var canvas = document.getElementById("canvas1");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(0,200,0,1)";
ctx.fillRect = (36,10,50,50);
}
</script>
</head>
<body>
<canvas id="canvas1" width="400" height="300">
This text is displayed if your browser
does not support HTML5 Canvas.
</canvas>
</body>
</html>
这看起来很简单,但它对我不起作用!