的特性「的getContext」這是我的HTML代碼,顯示畫布:遺漏的類型錯誤:無法讀取空
<canvas id="backgroundCanvas" width="550" height=600"></canvas>
<canvas id="playerCanvas" width="550" height=600"></canvas
<canvas id="enemiesCanvas" width="550" height=600"></canvas>
這是哪裏出了問題,據說發生:
game.contextBackground = document.getElementById("backgroundCanvas").getContext("2d"); // line 32
game.contextPlayer = document.getElementById("playerCanvas").getContext("2d"); // line 33
game.contextEnemies = document.getElementById("enemiesCanvas").getContext("2d"); // line 34
錯誤發生在那裏說:行34:
Uncaught TypeError: Cannot read property 'getContext' of null
任何幫助是非常讚賞:)
你有中間畫布上'typo':' canvas' – Hackerman