我在 this.show()
行上收到错误 "';'预期。”
。我对 js 很陌生,所以我认为这是一个简单的错误,但我无法弄清楚。
function Cell(i,j , height , width , color) {
this.cellColor = color ;
this.cellWidth = width ;
this.cellHeight = height;
this.x = j; // num from left
this.y = i; // num from top
this.connectedLimeCells = [];
this.connectedBlocks = [];
this.connectedOpenWhites = [];
this.neighbors = [] ;
this.show(){
fill(this.cellColor) ;
noStroke();
rect(this.x * this.cellWidth , this.y * this.cellHeight , this.cellWidth , this.cellHeight);
}
}
最佳答案
现在您正在调用您的方法。
this.show()
因此解析器在调用 this.show
后需要一个 ;
。
你的意思是:
this.show = () => {}
关于javascript - ';'预期的 。在函数 p5.js Javascript 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63903151/