firebaseui.js:formatted:9514未捕获的TypeError:无法读取未定义的属性'EmailAuthProvider'

时间:2018-08-22 01:10:28

标签: javascript firebase firebase-authentication firebaseui

我想使用Firebase UI,但我使用了它,第一次运行良好,但坏了

This is the the error on my page

但是我不认为这有问题,因为它是Firebase UI本身的代码

这是我在 index.html

中拥有的代码
<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://www.gstatic.com/firebasejs/5.0.4/firebase.js"></script>
  <script>
    var config = {
      apiKey: "**************************",
      authDomain: "chat-77ca3.firebaseapp.com",
      databaseURL: "https://chat-77ca3.firebaseio.com",
      projectId: "chat-77ca3",
      storageBucket: "chat-77ca3.appspot.com",
      messagingSenderId: "312413147357"
    };
    firebase.initializeApp(config);
  </script>
  <title>Chat</title>
  <script defer="defer" src="https://www.gstatic.com/firebasejs/5.0.4/firebase-app.js"></script>
  <script defer="defer" src="https://www.gstatic.com/firebasejs/5.0.4/firebase-database.js"></script>
  <script defer="" src="/__/firebase/init.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="https://cdn.firebase.com/libs/firebaseui/3.3.0/firebaseui.js"></script>
  <link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/3.3.0/firebaseui.css" />
  <script src="node_modules/firebaseui/dist/firebaseui.js"></script>
  <script type="text/javascript">
    var uiConfig = {
      signInSuccessUrl: 'loggedin.html',
      signInOptions: [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID,
        firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
      ]
    }
    var ui = new firebaseui.auth.AuthUI(firebase.auth());
    ui.start('#firebaseui-auth-container', uiConfig);
  </script>
</head>

<body>
  <div id="firebaseui-auth-container"></div>
</body>

</html>

这是 loggedin.html

中的javascript

不包含HTML

< script type = "text/javascript" >
  initApp = function() {
    firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        var displayName = user.displayName;
        var email = user.email;
        var emailVerified = user.emailVerified;
        var photoURL = user.photoURL;
        var uid = user.uid;
        var phoneNumber = user.phoneNumber;
        var providerData = user.providerData;
        user.getIdToken().then(function(accessToken) {
          document.getElementById('sign-in-status').textContent = 'Signed in';
          document.getElementById('sign-in').textContent = 'Sign out';
          document.getElementById('account-details').textContent = JSON.stringify({
            displayName: displayName,
            email: email,
            emailVerified: emailVerified,
            phoneNumber: phoneNumber,
            photoURL: photoURL,
            uid: uid,
            accessToken: accessToken,
            providerData: providerData
          }, null, '  ');
        });
      } else {
        document.getElementById('sign-in-status').textContent = 'Signed out';
        document.getElementById('sign-in').textContent = 'Sign in';
        document.getElementById('account-details').textContent = 'null';
      }
    }, function(error) {
      console.log(error);
    });
  };

window.addEventListener('load', function() {
  initApp()
}); 

</script>

0 个答案:

没有答案