我正在尝试在p5js编辑器上使用firebase服务。我遵循了有关如何设置和启动Firebase的文档,但是仍然出现错误“ firebase未定义” ...
这是我的代码:
function setup() {
createCanvas(400, 400);
var config = {
apiKey: "omit",
authDomain: "omit",
databaseURL: "omit",
projectId: "omit",
storageBucket: "omit",
messagingSenderId: "omit"
};
firebase.initializeApp(config);
}
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.sound.min.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.6.0/firebase.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<script src="sketch.js"></script>
</body>
</html>
答案 0 :(得分:0)
我认为它应该可以工作,但是您必须放置脚本
<script src="sketch.js"></script>
在身体标签之外。它不是应该的位置。