자바 스크립트와 함께 Firebase를 사용할 때 '초기화 전에'firebase '에 액세스 할 수 없습니다.'오류가 발생합니다.

Cemgem

이것은 HTML 코드입니다. Firebase를 JavaScript와 함께 사용할 때 "Cannot access 'firebase'before initialize"오류가 발생합니다. 태그를 이동하려고했지만 작동하지 않는 것 같습니다.

<!DOCTYPE html>
<html lang="en" dir="ltr">
    <head>
        <title>Login</title>
        <meta charset="utf-8">
    </head>
    <body>
        <script src="https://www.gstatic.com/firebasejs/7.15.1/firebase-app.js"></script>
        <script src="https://www.gstatic.com/firebasejs/7.15.4/firebase-auth.js"></script>
        <script src="https://www.gstatic.com/firebasejs/7.15.4/firebase-firestore.js"></script>
        <script src="form.js"></script>
        <section>
            <input id="email" name="email" placeholder="email">
            <input id="password" name="password" placeholder="password">

            <button onclick=signUp() id="signUp" type="button">Sign Up</button>
        </section>
    </body>
</html>

매개 변수가없는 JS 코드입니다.

var firebaseConfig = {
apiKey: 
authDomain: 
databaseURL:
projectId: 
storageBucket: 
messagingSenderId: 
appId: 
measurementId:
};
  // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
    firebase.analytics();

const firebase = firebase.auth();

function singUp() {
    var email = document.getElementById("email");
    var password = document.getElementById("password");

    const promise = auth.createUserWithEmailAndPassword(email.value, password.value);
    promise.catch(e => alert(e.message));

    alert("Signed Up");
}

firebase를 초기화하는 것 같지 않습니다. 무엇이 잘못되었는지 알고 있습니까?

Aishwarye Chauhan

교체 시도 const firebase = firebase.auth();와 함께const auth = firebase.auth();

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관