简体   繁体   English

我该如何解决这个未捕获的ReferenceError?

[英]how do i fix this Uncaught ReferenceError?

I am pretty new to java script. 我对Java脚本很陌生。 I am following along on a tutorial on how to get firebase to authorize on my page. 我正在遵循有关如何在我的页面上获得Firebase授权的教程。 I just have a simple button that SHOULD pull up the google login. 我只是有一个简单的按钮,应该拉起Google登录名。

The error is "(index):96 Uncaught ReferenceError: googlelogin is not defined at HTMLButtonElement.onclick ((index):96) onclick @ (index):96" 错误为“(index):96 Uncaught ReferenceError:未在HTMLButtonElement.onclick((index :: 96)onclick @(index):96)定义googlelogin”

Im pretty certain this is an easy fix. 我很确定这是一个简单的解决方法。 Like I said, fairly new. 就像我说的那样,很新。 Thanks in advance! 提前致谢!

In the HTML 在HTML中

<body>
    <h1>testing</h1>
    <button onclick="googlelogin()">login</button> 

    <script>
        src = "app.js"
    </script>
</body>

In app.js 在app.js中

document.addEventListener("DOMcontentloaded", event => {

        const app = firebase.app();
        console.log(app)

    )
}

function googlelogin() {
    const provider = new firebase.auth.GoogleAuthProvider();

    firebase.auth().signupwithpopup(provider)

    .then(result => {
            const user = result.user
            document.write('Hello $(user.displayname');
            console.log(user)
        })
        .catch(console.log)

Your current code just sets a global variable called src to the value of app.js . 您当前的代码只是将名为src的全局变量设置为app.js的值。 I think you want to actually load app.js 我认为您想实际加载 app.js

<body>
    <h1>testing</h1>
    <button onclick="googlelogin()">login</button> 

    <script src="app.js"></script>
</body>

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

相关问题 如何修复“未捕获的ReferenceError:未定义FB”? - How do I fix “Uncaught ReferenceError: FB is not defined”? 如何修复我的代码:错误:未捕获的 ReferenceError:未定义帐户? - How do I fix my code :error: Uncaught ReferenceError: account is not defined? 尝试从外部文件导入类时,如何解决Typescript中的Uncaught ReferenceError? - How do I fix Uncaught ReferenceError in Typescript when trying to import class from external file? 我如何修复错误 Uncaught ReferenceError: addEvent is not defined - How can i fix the error Uncaught ReferenceError: addEvent is not defined 如何修复 Uncaught (in promise) ReferenceError: require is not defined with Vite? - How can I fix Uncaught (in promise) ReferenceError: require is not defined with Vite? 如何修复未捕获的 ReferenceError:未定义 TimelineMax - How to fix Uncaught ReferenceError: TimelineMax is not defined 如何修复“Uncaught ReferenceError: nameCheck is not defined”错误? - How to fix “Uncaught ReferenceError: nameCheck is not defined” error? 如何修复未捕获的 ReferenceError:熔岩未定义 - How to fix Uncaught ReferenceError: lava is not defined 如何修复未捕获的 ReferenceError:未定义要求 - How to fix Uncaught ReferenceError: require is not defined 如何修复“ Uncaught ReferenceError:未定义firebase”错误? - How to fix “Uncaught ReferenceError: firebase is not defined” error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM