HTML:
<html>
<head>
<link rel="stylesheet" href="index.css">
<title>sdssd</title>
<meta charset="UTF-8">
</head>
<body>
<canvas id="area">
</canvas>
</body>
<footer>
<script type="text/javascript" src="index.js"></script>
</footer>
</html>
CSS:
#area {
width: 600px;
height: 600px;
margin: auto 30%;
background-color: lightgray;
outline: 1px solid black;
}
JS:所有这些都很裸露,我只想暂时绘制一个形状,但是context.fillRrect似乎不起作用...我不知道为什么
var canvas = document.getElementsByTagName("canvas")[0];
var context = canvas.getContext("2d");
context.fillStyle("red");
context.fillRect(4, 5, 132, 132);
答案 0 :(得分:1)