javascript - Uncaught ReferenceError: firebase is not defined, in web application
问题描述
我在我的 Web 应用程序中遇到了一个奇怪的问题。实际上我正在使用 Firebase 托管,并且我正在尝试在我的网页中创建一个“注销”按钮。我说这很奇怪,因为我为登录编写的名为“login.js”的 JavaScript 文件工作正常。但是对于注销功能,它是说“未捕获的 ReferenceError:未定义火力”。
在这里,我发布了我编写的脚本-
HTML-
<div class="subSetingOptionList">
<button onclick="logOut()">Logout</button>
</div>
JavaScript-
// ON AUTH STATE CHANGES
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// USER IS SIGNED IN
document.getElementById("showIfNotLogIn").style.display = "none";
document.getElementById("onUserLogin").style.display = "block";
} else {
// No user is signed in.
document.getElementById("showIfNotLogIn").style.display = "block";
document.getElementById("onUserLogin").style.display = "none";
}
});
//THIS PART IS WORKING FOR SURE
function letMeLogin(){
let usernaming = document.getElementById("userNameForLogin").value;
let userpasswording = document.getElementById("userPasswordForLogin").value;
firebase.auth().signInWithEmailAndPassword(usernaming, userpasswording).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
window.alert(`Alert: ${errorMessage}`);
});
}
//THIS IS THE PART FOR LOGOUT WHICH IS GIVING THE ERROR
function logOut(){
firebase.auth().signOut().then(function() {
// Sign-out successful.
}).catch(function(error) {
// An error happened.
});
}
解决方案
推荐阅读
- javascript - 如何替换网站的 javascript 功能?
- python-3.x - numpy数组的真假索引
- javascript - JavaScript图像调整大小导致白色/黑色图像
- c# - 任务已计划并等待运行但从未执行
- javascript - Bootstrap 4:如何显示一个可折叠项目并隐藏其他项目?
- graphics - GPU Basic : 为什么要处理计算机图形的浮点数
- c# - 如何检查 SQL 数据库中的空列值,C#
- kaggle - Kaggle 数据集下载
- java - 字符串的 JPA 规范搜索列表包含
- javascript - Laravel ajax 分页加载整个页面