[英]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.