如何在HTML和JavaScript中初始化firebase

如何在HTML和JavaScript中初始化firebase,javascript,html,firebase,Javascript,Html,Firebase,我在index.html中添加了以下脚本 如果没有更多信息,我将把它放在这里以防万一 它位于的底部,就在标记之前 <!-- Firebase App (the core Firebase SDK) is always required and must be listed first --> <script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js"></scri

我在index.html中添加了以下脚本


如果没有更多信息,我将把它放在这里以防万一

它位于
的底部,就在
标记之前

<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js"></script>
<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-analytics.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.0/firebase-storage.js"></script>

<!-- initialize app -->
<script src="/__/firebase/init.js"></script>

您正在使用的以
/\uuu
开头的URL是保留的URL,当您使用Firebase主机时要使用,请参阅文档和

“当您部署到Firebase(
Firebase deploy
)或在本地服务器上运行应用程序(
Firebase Service
)时,它们将正常工作”

如果您使用另一个托管解决方案,或者尝试直接从文件系统执行HTML页面,那么它将无法工作


我知道您在问题中共享的JS文件是您在
index.html
文件中声明的
init.JS
文件

为您自己的JS文件使用
/\uu
路径前缀将不起作用:换句话说,您不能为您自己的文件使用保留URL。您需要在
index.html
文件中,指向根目录下
init.js
文件的路径(默认情况下名为
public
,请参阅)


换句话说,如果
index.html
init.js
在同一个
public
文件夹中,只需执行

在index.html中添加脚本的位置?控制台中有什么?所有firebase库是否都正确加载?@PeterHaddad在@Beerswiller下显示“初始化前无法访问firebase”。我从firebase项目中获取的链接不包含gstatic.com。我想是旧版本的吧。我需要使用你在这里提到的相同链接吗。它们现在有效吗?