这里我将senderId
检索为sID
,将recieverId
检索为rID
。但在检索后,我无法在连接时访问这两个id。如何在此查询外部访问这两个id。请帮忙。
以下是代码
var ref = firebase.database().ref("cUsers");
ref.orderByChild("email").equalTo(senderEmail).on("child_added", function (snapshot){
var sID = snapshot.val().uid;
alert(sID);
});
ref.orderByChild("email").equalTo(email).on("child_added", function (snapshot) {
var rID = snapshot.val().uid;
alert(rID);
});
var chatUsers=sID+"_"+rID;
答案 0 :(得分:0)
这应该有用。
var sID = '';
var rID = '';
var ref = firebase.database().ref("cUsers");
ref.orderByChild("email").equalTo(senderEmail).on("child_added", function (snapshot){
sID = snapshot.val().uid;
alert(sID);
});
ref.orderByChild("email").equalTo(email).on("child_added", function (snapshot) {
rID = snapshot.val().uid;
alert(rID);
});
var chatUsers=sID+"_"+rID;