【发布时间】:2019-03-24 23:15:09
【问题描述】:
我收到错误“未捕获的类型错误:firebase.auth 不是函数”。
我的代码运行良好,然后我实现了我的客户 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)
但这会导致同样的错误。
【问题讨论】:
-
您是否为 auth 添加了适当的 Firebase 脚本/模块?
-
目前我只包括所有使用的firebase服务:
-
我将使用缩减的
firebase-app.js文件检查任何其他<script>标签,因为这将覆盖firebase变量。还要检查firebase = ...的任何使用 -
原来有,这就是我所做的。我现在已经设法让两个 Firebase 应用程序都初始化并正常运行 - 感谢您的帮助。
标签: javascript firebase firebase-authentication