我无法将对象推送到数组。
这是代码:
snapshot.forEach(function(childSnapshot) {
var item = childSnapshot.val();
item.key = childSnapshot.key;
var data = {
name: item.name,
price: item.price,
details: item.details
};
this.products.push(data);
});
products是一个空数组。
products:[]
我在控制台日志中看到数据:
{name: "java", price: "zero", details: "nothing"}
{name: "nfdg", price: 145, details: "fkshfksf"}
{name: "nfdg", price: 145, details: "fkshfksf"}
{name: "nfdg", price: 145, details: "fkshfksf"}
{name: "nfdg", price: 145, details: "fkshfksf"}
谢谢
答案 0 :(得分:0)
)