前几天开始学习p5.js,现在想用IntelliJ IDEA代替p5.js online editor .大多数东西像setup()
, draw()
和 ellipse()
功能按预期工作,但 createCanvas()
函数没有 - 它带有绿色下划线,错误消息显示“未解析的函数或方法 createCanvas()”。
我尝试使用 VSCode,它运行得很好,但我更喜欢使用 IntelliJ,所以我想知道我是否以及如果是的话,如何让它在 IntelliJ 中工作。
<script src="p5.js"></script> //p5.js is the file with all the code from the official p5js.org homepage.
<script src="sketch.js"></script> //sketch.js is the file where my code that should be executed is located
function setup() { //The setup() function is recognized as expected,
createCanvas(1000, 1000); //But the createCanvas() function isn't.
}
最佳答案
p5 函数定义为 p5.prototype.<function name> = function(){}
,所以 IDE 期望这里有一个命名空间...作为一种解决方法,请尝试安装 p5 类型:在 偏好 |语言和框架 | JavaScript |图书馆 , 按 下载... ,选择 p5
从列表中。这应该可以解决问题
关于javascript - IntelliJ IDEA 中的 P5.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58693151/