我收到错误“Uncaught TypeError: firebase.auth is not a function”。
我的代码运行完美,然后我实现了我的客户 api,发现他们的 api 已经使用并初始化了一个不同的 firebase 应用程序。因此,由于我无法以通常的方式(即 firebase.initializeApp(config) )初始化我的 firebase 应用程序,因此我遵循了有关初始化多个 firebase 应用程序的文档,如下所示。 (这导致错误)
var configOther = {
apiKey: "xxxx",
authDomain: "xxxx",
databaseURL: "xxxx",
projectId: "xxxx",
storageBucket: "xxxx",
messagingSenderId: "xxxx"
};
var firebaseOther = firebase.initializeApp(configOther, "firebaseOther");
console.log("auth: ", firebase.auth(firebaseOther)); //"Uncaught TypeError: firebase.auth is not a function"
关于我在这里做错了什么有什么想法吗?非常感谢。
注意 - 我还尝试了以下速记符号:
firebaseOther.auth()
代替
firebase.auth(firebaseOther)
但这会导致同样的错误。
最佳答案
您可能跳过了在页面中包含 firebase-auth 脚本的步骤,如 documentation 所述:
<!-- Firebase App is always required and must be first -->
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-app.js"></script>
<!-- Add additional services that you want to use -->
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-auth.js"></script>
关于javascript - firebase.auth 不是函数 - 具有多个 firebase 应用程序初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55329495/