这个函数将是循环的,每个循环 key1 和 key2 都会改变......问题是数据库结果是一个数组,它不会获取键的每个数据,它只会记录最后一个数据。
GettingData: function(key1,key2){
var list=[];
console.log('Getting Data of '+key2);
var ref = firebase.database().ref('/users/'+key1+'/products/'+key2).orderByKey().equalTo('name');
ref.on('child_added', function(data) {
console.log(data.val());
list.unshift(data.val());
this.databaseresult = list;
console.log('Productdata of '+ key1 +' is LOADED');
console.log('pushing to array '+list);
console.log(this.databaseresult);
this.$.results.products = this.databaseresult;
}.bind(this));
},