javascript - 未捕获的 ReferenceError:未定义接收
问题描述
(现在已修复)(如果您想使用此功能,请记住将其放在 . 下方和之前实现一个功能,您可以在其中发布您的状态,其他人可以根据您一开始获得的 google 登录名查看其他人写的内容。我在 html doc 中编写 Javascript,旁边有一个 CSS。我使用了带有 NODE.JS 的 firebase 托管、云和实时数据库。我的一些代码基于这个绅士的视频: https://youtu.be/QuiZE5ZE4EE (Paul Baumgarten) 这是确切的错误:
Uncaught ReferenceError: receive is not defined
at receiveUpdate ((index):141)
at firebase-app.js:1677
at fc (firebase-app.js:1677)
at bf (firebase-app.js:1677)
at cf (firebase-app.js:1677)
at Object.G (firebase-app.js:1677)
at firebase-app.js:1677
at Ag.g.wd (firebase-app.js:1677)
at og.wd (firebase-app.js:1677)
at Yf.Xf (firebase-app.js:1677)
html:
var config = {
apiKey: "AIzaSyC1ls01V0-7A1nCnZwfnuBsUwaboTUOE1E",
authDomain: "ariadnes-string.firebaseapp.com",
databaseURL: "https://ariadnes-string.firebaseio.com",
projectId: "ariadnes-string",
storageBucket: "ariadnes-string.appspot.com",
messagingSenderId: "737704779364"
};
firebase.initializeApp(config);
function login() {
function newLoginHappened(user) {
if (user) {
// User is signed in
app(user);
} else {
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider);
}
}
firebase.auth().onAuthStateChanged(newLoginHappened)
}
function app(user) {
// user.displayName
// user.email
// user.photoURL
// user.uid
function updateMyStatus(e) {
var myUpdate = {};
myUpdate.email = user.email;
myUpdate.displayName = user.displayName;
myUpdate.status = document.getElementById("clientStatus").value;
fb.child("user.uid").set(myUpdate);
}
function receiveUpdate(received) {
var data = received.val();
console.log(data);
document.getElementById("messages").innerHtml = "";
for (var key in data) {
var person = data[key];
var p = "<p>" + person.displayName + " (" + person.email + ") said:" + person.status + "</p>";
document.getElementById("messages").innerHTML += p;
}
}
document.getElementById("clientName").innerHTML = user.displayName;
document.getElementById("clientPhoto").setAttribute("src", user.photoURL)
var fb = firebase.database().ref("whatsmystatus");
document.getElementById("clientStatus").addEventListener("input", updateMyStatus);
fb.on("value", receiveUpdate);
}
window.onload = login;
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GSS</title>
<link href="GSS_Home_Style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
</head>
<header>
<img src="logo.png" alt="logo" class="logo" />
<input type="checkbox" id="nav-toggle" class="nav-toggle">
<nav>
<ul>
<li><a href="GSS_Home_Html.html">Home</a></li>
<li><a href="#">Forums</a></li>
<li><a href="#">Settings</a></li>
<li><a href="#">Support</a></li>
<li><a href="GSS_Login_Html.html">Login</a></li>
</ul>
</nav>
<label for="nav-toggle" class="nav-toggle-label">
<span></span>
</label>
</header>
<div class="loginbox">
<img id="clientPhoto" src="" class="avatar">
<h1>Hello <span id="clientName"></span></h1>
<form>
<div style="text-align: center">
<div style="padding-bottom: 20px;">
<p>What is your current status?</p>
<div>
<input type="text" id="clientStatus" maxlength="100" placeholder="Status...">
</div>
<p>Other people have left the following status messages:</p>
<div id="messages"></div>
</div>
</div>
</form>
</div>
<section id="hideonmobile2">
<div class="loginboxright">
<h1>Latest News</h1>
<form>
<div style="text-align: center">
<div style="padding-bottom: 20px;">
<p>Currently working on website - desktop program under construction</p>
<p>Welcome to "Gamer's String". Our program is buildt to make an amazing community where you can post, view and complete tips and tricks. Get your post to the top by leveling up or purchasing our pro version. <strong>Good luck!</strong></p>
</div>
</div>
</form>
</div>
</section>
<section id="hideonmobile3">
<footer>
<div class="footer-social-icons">
<ul class="social-icons">
<li>
<a href="
https://www.facebook.com/ariadnes.string.9" class="social-icon">
<i class="fa fa-facebook"></i></a>
</li>
</ul>
</div>
</footer>
</section>
<section id="showonmobile1">
<footer>
<div class="footer-social-icons">
<ul class="social-icons">
<li>
<a href="https://www.facebook.com/ariadnes.string.9" class="social-icon"><i class="fa fa-facebook"></i></a>
</li>
</ul>
</div>
</footer>
<script src="https://www.gstatic.com/firebasejs/3.8.0/firebase.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script> <script src="#"> </script>
我确实有一个 CSS,但我认为这并不重要,
我将非常感谢任何帮助。
解决方案
推荐阅读
- forms - 如何根据flutter中的下拉列表添加文本字段值
- javascript - 数字被连接而不是相加
- azure-devops - Terraform:构建 ARM 配置时出错 - 仅支持使用 Azure CLI 进行身份验证
- c++ - 将 ifstream 对象传递给函数并在两者之间使用 getline()
- javascript - 服务调用不会以反应原生方式进行。收到类似“可能未处理的承诺拒绝,参考错误:未定义响应”的警告
- sapui5 - 如何在 HBox/VBox 中排列输入字段?
- firebase - 如何在 Firebase 分析中邀请其他用户
- .net-core - 如何为 Json 声明类型映射 MapUniqueJsonKey
- c++ - 在系统上已经安装 Oracle Server 的情况下安装 ODAC 的目的是什么
- java - JSON - 不包含完整数据的键值对