Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

javascript - Getting error Uncaught ReferenceError: firebase is not defined

I have tried too many things and read too many documents but can't find the solution

My html:-

<html>
  <head>
    <script src='https://www.gstatic.com/firebasejs/8.2.2/firebase.js'></script>
   
  </head>

<body onload="Initialize_Firebase()">
  <input type="text/submit/hidden/button/image" id="Name" value="" />
  <input type="text/submit/hidden/button/image" id="Password" value="" />
  <button type="submit">enter</button>
  
  
  
  
  <script src="Config.js"></script>
  
</body>

</html>

My js:-


function Initialize_Firebase(){
  
  var firebaseConfig = {
    apiKey: "** MY API KEY **",
    authDomain: "*****.firebaseapp.com",
    databaseURL: "https://****.firebaseio.com",
    projectId: "****",
    storageBucket: "****.appspot.com",
    messagingSenderId: "16*****54",
    appId: "1:168*****4:web:29d43b******d3a38b",
    measurementId: "G-JBZC**YYV"
  };
  // Initialize Firebase
firebase.initializeApp(firebaseConfig);
  
}

Error log:-

Uncaught ReferenceError: firebase is not defined 1/12/2021, 3:58:58 PM /Database.js:14:1


I have even copied and pasted some other scripts to html as they where written in Docs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding the script of firebase-app too

<script src="https://cdnjs.cloudflare.com/ajax/libs/firebase/8.2.2/firebase-app.min.js"></script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...