[英]unexpected token export firebase-app.js:1590
I am trying firebase web for first time, i was following the documentation still code isn't working and giving this "unexpected token 'export' " error in console.我第一次尝试 firebase web,我按照文档仍然代码不起作用并在控制台中给出了这个“意外的令牌'导出'”错误。 code:
代码:
<!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>
please help, thank you请帮忙,谢谢
The v9 SDKs are shipped as JavaScript modules by default.默认情况下,v9 SDK 以 JavaScript 模块的形式提供。 To use them in a regular JavaScript import, and to use your style of code, you can instead import the compatibility layer as shown in the documentation on using the compat library from your window :
要在常规 JavaScript 导入中使用它们,并使用您的代码风格,您可以导入兼容层,如有关使用 window 中的兼容库的文档中所示:
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-auth-compat.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.