这是 draw.js 文件中的内容,错误似乎与第 11 行和第 13 行有关
const canvas = document.querySelector(".canvas");
const ctx = canvas.getContext("2d");
const scale = 10;
const rows = canvas.height / scale;
const columns = canvas.width / scale;
console.log("hello world")
var snake;
(function setup() {
snake = new Snake();
snake.draw();
}())
snake.js 文件内容
function snake() {
this.x = 0;
this.y = 0;
this.draw = function() {
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(this.x, this.y, scale, scale);
}
}