简体   繁体   English

如何修复“ Uncaught ReferenceError:未定义firebase”错误?

[英]How to fix “Uncaught ReferenceError: firebase is not defined” error?

I created an application using Firebase-CLI and I wrote a code to redirect when the user logged in to another location also when he did not. 我使用Firebase-CLI创建了一个应用程序,并编写了一个代码以在用户登录到其他位置以及在用户未登录时重定向。 But when I try the serve it's not working 但是当我尝试发球时却没有效果

Here is my html code 这是我的HTML代码

<!DOCTYPE html>
<html>
  <head>
    <title>JTM Check</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>

    <!-- update the version number as needed -->
    <script defer src="/__/firebase/6.0.2/firebase-app.js"></script>
    <script defer src="/__/firebase/6.0.2/firebase-auth.js"></script>
    <script defer src="/__/firebase/init.js"></script>
    <script>
      firebase.auth().onAuthStateChanged(function(user) {
        if (user) {
          // User is signed in.
        } else {
          // No user is signed in.
        }
      });    
    </script>
  </body>
</html>

and here is the error 这是错误

(index):15 Uncaught ReferenceError: firebase is not defined (索引):15未捕获的参考错误:未定义Firebase

at (index):15 在(索引):15

(anonymous) @ (index):15 (匿名)@(索引):15

remove defer from your scripts 从脚本中删除defer

when present, it specifies that the script is executed when the page has finished parsing. 如果存在,它指定在页面完成解析后执行脚本。 so your script is executing before firebase is loaded 因此您的脚本在加载firebase之前正在执行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM