javascript - ';'预期的 。在函数 p5.js Javascript 中

标签 javascript p5.js

我在 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/

相关文章:

javascript - p5.j​​s && ecmascript6 表示法

javascript - 试图从数组中检索对象的颜色

javascript - 这个jquery有什么问题?

javascript - Javascript 中乘法之前的除法是怎样的?

javascript - Visual Studio Code ES7/JS 智能感知

javascript - 如何从 .mp3 音乐文件中检测音符,然后显示 MIDI 时间图

javascript - 函数 arc() 无法在 p5.js 中正确呈现

javascript - 如何返回Parse Query结果进行查看?

javascript - mustache JS : fill multiple divs with different content

javascript - 我的 p5.js 代码有时会滞后,我不知道怎么办?