我试图使用HTML5整理网站。我试图使用Javascript的canvas元素。我正在查看YouTube视频,我确定我正确地关注了所有内容,但我没有得到任何内容。有人可以查看代码,看看我是否遗漏了任何内容。
<html>
<head>
<script type=”text/javascript”>
window.onload=loader;
function loader()
{
var canvasI = document.getElementById("forcanvas");
var canvasII = canvasI.getContext("2d");
canvasII.fillStyle ="rgba(0, 0, 200, 1)”;
canvasII.fillRect(30, 30, 75, 70);
}
</script>
</head>
<body>
<canvas id="forcanvas" width="500" height="500"></canvas>
</body>
</html>
答案 0 :(得分:1)
替换”
而不是"
试试这段代码:
<html>
<head>
<script type="text/javascript">
window.onload=loader;
function loader()
{
var canvasI = document.getElementById("forcanvas");
var canvasII = canvasI.getContext("2d");
canvasII.fillStyle ="rgba(0, 0, 200, 1)";
canvasII.fillRect(30, 30, 75, 70);
}
</script>
</head>
<body>
<canvas id="forcanvas" width="500" height="500"></canvas>
</body>
</html>