我正在尝试在SignUp类中创建UserNames列表,以仅允许创建唯一的displayNames。但是,当尝试按以下方式查看对象的displayName时,在控制台中,当映射初始对象时,我可以看到displayName,但是尝试将其存储为变量会使我无法确定该值。
function nameCheck(){
let userList = [];
db.collection("userNames").get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data()) //I can see the parameter displayName here with //proper value
console.log(doc.displayName) //here it is being logged as undefined
});
console.log(userList); //I can see the array has the right amount of objects, but they are all //undefined
});
我敢肯定这很简单,但我根本无法使用。
我想你的意思是说:
console.log(doc.data().displayName)
文档属性的值位于所返回的对象中data()
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句