p5.js && ecmascript6 notation
问题 I want use p5.js function inside a class with ECMAScript notation. How to fix this code? class Sketch { constructor(p, params) { // generate vars use in class with object if (typeof params !== 'undefined') { for (let key in params) this[key] = params[key]; } // p5.js object this.p = p; } // p5.js setup method setup() { this.p.createCanvas(); } // p5.js draw method draw() { } } sketch = new Sketch(p5,{}); Error: this.p.createCanvas is not a function 回答1: The docs say that you must instantiate