我的渲染器.js代码:// Your web app's Firebase configurationvar firebaseConfig = { apiKey: "some API key", authDomain: "some auth domain", databaseURL: "some database url", projectId: "some project id", storageBucket: "some storagebucket", messagingSenderId: "some messaging sender id", appId: "some app id", measurementId: "some measurement id" }; // Initialize Firebase firebase.initializeApp(firebaseConfig); var bcont = document.getElementById('bcont'); bcont.addEventListener('click',function(){ var firstname = document.getElementById('fn').value; var lastname = document.getElementById('ln').value; var email = document.getElementById('email').value; var password = document.getElementById('pass1').value; var cpassword = document.getElementById('pass2').value; firebase.auth().createUserWithEmailAndPassword(email,password).catch(function(error){ if(error != null){ console.log(error.message); return; } alert('Success'); }) });索引.html代码:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <link rel="stylesheet" href="../assets/css/main.css"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <title></title> </head>我在控制台中收到错误Uncaught Reference Error: firebase is not defined.我该如何解决这个问题?另外:如何存储名字和姓氏以及电子邮件+密码?请注意:这是正确的链接,我只启用了电子邮件/密码登录方法。不知道在这里做什么,任何帮助将不胜感激!
1 回答
烙印99
TA贡献1829条经验 获得超13个赞
您应该按正确的顺序放置包含的内容:
<script src="https://www.gstatic.com/firebasejs/7.14.5/firebase-app.js"></script>
<script src="renderer.js"></script>
所以渲染器.js知道firebase的存在。
添加回答
举报
0/150
提交
取消