나는 단순한 탁구 게임을 만들기 위해 udemy 코스를 사용했습니다. 연습으로 다시 작성 중이며 오류 캔버스가 계속 null로 표시됩니다. 어떤 도움?내 HTML 캔버스가 null입니다. 정말 성가 시게
<html>
<canvas id="gamecanvas" width="600" height="800"></canvas>
<script>
var canvas = null;
var Context = null;
window.onload = function(){
canvas.document.getElementById("gamecanvas");
Context.canvas.getContext("2d");
drawEverything();
}
function drawEverything() {
Context.fillStyle = "black";
Context.fillRect(0,0,canvas.width,canvas.height);
Context.fillStyle = "white";
Context.fillRect(0,360,20,80);
Context.fillStyle = "white";
Context.fillRect(580,360,20,80);
Context.fillStyle = "green";
context.beginpath();
context.arc(0,0,10,10,Math.PI*2,true);
context.fill();
}
아마도'onload' 함수에서'canvas = document.getElementById ("gamecanvas")'가 끝났습니까? –
'canvas.document'를하고 있습니다. 기본적으로'null' 객체의'document' 속성에 접근하려고 시도합니다. –
'context! = Context' 때문에 문제가 발생할 것입니다. –