第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

等到在 Firebase 數(shù)據(jù)庫(網(wǎng)絡(luò))中檢測到新數(shù)據(jù)

等到在 Firebase 數(shù)據(jù)庫(網(wǎng)絡(luò))中檢測到新數(shù)據(jù)

慕無忌1623718 2022-05-26 14:15:46
在此示例中,我想在 firebase 數(shù)據(jù)庫的父節(jié)點(diǎn)中創(chuàng)建一個(gè)名為“friend”的新節(jié)點(diǎn)時(shí)更改站點(diǎn)。我不知道如何讓它等到它檢測到新節(jié)點(diǎn)。    var friendUid;    firebase.database().ref('users/' + uid).child('friend').on('value', function(snapshot){       friendUid = snapshot.val();    })    while(!friendUid){ //I've also tried with "friendUid == null"     firebase.database().ref('users/' + uid).child('friend').on('value', function(snapshot){       friendUid = snapshot.val();     })    }    window.document.location = "whatever.html";
查看完整描述

1 回答

?
牧羊人nacy

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超7個(gè)贊

您不需要循環(huán),但您確實(shí)需要將更改位置的代碼移動到偵聽器中:


firebase.database().ref('users/' + uid).child('friend').on('value', function(snapshot){

  var friendUid = snapshot.val();

  if (friendUid == "what you're looking for") {

    window.document.location = "whatever.html";

  }

})

如果您只想檢查節(jié)點(diǎn)是否存在,可以簡化為:


firebase.database().ref('users/' + uid).child('friend').on('value', function(snapshot){

  if (snapshot.exists()) {

    window.document.location = "whatever.html";

  }

})


查看完整回答
反對 回復(fù) 2022-05-26
  • 1 回答
  • 0 關(guān)注
  • 105 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號