[英]Firebase real-time database posting over old images with JavaScript
[英]JavaScript: alerting a specific value on my real-time database
我一直在努力实现以下目标,但我做不到
如果我想提醒ada的名字,我应该使用什么代码?
我用这个,它返回未定义的:
if (user) {
// User is signed in.
alert('user signed')
// Get a reference to the database service
var database = firebase.database();
var query = firebase.database().ref("users");
query.once("value")
.then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
// key will be "ada" the first time and "alan" the second time
var key = childSnapshot.key.val;
// childData will be the actual contents of the child
var childData = childSnapshot.val();
alert(key);
});
但这没用,有什么建议吗?
注意:JavaScript全新
在文档中 ,它是
// key will be "ada" the first time and "alan" the second time
var key = childSnapshot.key;
不是var key = childSnapshot.key.val;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.