我有以下对象:
root: {
id1: { /* this is an autogenerated id by Firebase */
name1: "abc",
name2: "xyz"
},
id2: {
name1: "abc",
name2: "xyz"
},
id3: {
name1: "abc",
name2: "xyz"
},
}
我检索整个快照的代码是:
getRoot () {
firebase.database ().ref ('roots/')
.on('value', function (snapshot) {
console.log (snapshot.val());
})
}
一切都很完美。我从根组件中获取了所有对象,但我无法弄清楚如何访问ID及其子代?谢谢!