【发布时间】:2021-12-04 13:06:19
【问题描述】:
我在尝试将用户添加到 Firebase 身份验证时遇到错误。 const auth 是在加载脚本之前定义的。我尝试使用和不使用 app 参数进行调用。没有添加用户,我似乎无法弄清楚这个错误。我只删掉了我认为相关的代码。抱歉,如果这是一个愚蠢的问题,我只是深入研究 HTML 和 JS。
错误:未捕获的 ReferenceError:未定义身份验证
在 HTMLFormElement。 (auth.js:12)
来自 html 文件:
import { getAuth, createUserWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/9.1.3/firebase-auth.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.1.3/firebase-app.js";
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
<script src="js\auth.js"></script>
来自js文件:
auth.createUserWithEmailAndPassword(email, password).then(cred => {
console.log(cred);
});
【问题讨论】:
-
This 可能会有所帮助。
-
嗨,Rob,感谢您对此进行调查。实际上,我通过之前的搜索发现了该帖子,但他们推荐的解决方案似乎是必须在导入脚本之前声明身份验证,我相信这是我的设置方式,除非我弄错了。
标签: javascript html firebase firebase-authentication