';'预期的 。在函数中 p5.js Javascript
';' expected . In function p5.js Javascript
我在行 this.show()
上收到一个错误 " ';' expected. "
。我对 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 = () => {}
我在行 this.show()
上收到一个错误 " ';' expected. "
。我对 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 = () => {}