【发布时间】:2021-09-11 22:45:42
【问题描述】:
我第一次尝试firebase web,我一直在关注文档,但代码仍然不起作用,并在控制台中给出了这个“意外令牌\'export\'\”错误。 代码:
<!DOCTYPE html>
<html>
<head>
<title> Firebase Demo </title>
<script src=\"https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js\"/>
<script src=\"https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js\"/>
<script src=\"https://www.gstatic.com/firebasejs/9.0.2/firebase-database.js\"/>
<script>
const firebaseConfig = {
#firebase config info
};
// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const database = firebase.database();
database.ref(\"List/\"+\"Targets\").set({
name:\"niel\",
state:\"alive\"
});
</script>
</head>
<body>
<h1 align=\"center\">Firebase Jinx</h1>
</body>
</html>
请帮忙,谢谢
-
export仅在模块中有效。使用<script type=\"module\">导入模块。
标签: javascript firebase-realtime-database