javascript - IntelliJ IDEA 中的 P5.js?

标签 javascript intellij-idea p5.js

前几天开始学习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从列表中。这应该可以解决问题

enter image description here

关于javascript - IntelliJ IDEA 中的 P5.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58693151/

相关文章:

javascript - 结合进度条将文本颜色更改为特定宽度?

javascript - 在图表中使用 ajax 响应值

java - 将 VisualVM 与 IntelliJ 结合使用

java - IntelliJ 想法 : build and run Java apps in docker containers

javascript - 在没有设置/绘图格式的情况下使用 p5 的功能

javascript - P5.js 用矩形绘制圆形

p5.js - 如何从 p5.js 更改 HTML 元素中的文本?

javascript - 使用 Ext.ajax.Request 以非 json 格式提交负载数据

java - Intellij 无法检测到@Slf4j 使用 Lombok 添加的记录器

javascript - 从谷歌时间轴图表中删除边框