我的班级有3个记录和3个对象。我如何迭代多个对象以及如何获得这些对象的细节,谢谢你的进步。
它正在使用一个对象ID手册
query.get("36iUEFs7YL",
{
success: function(res) {
var objectId=res.id;
var productName=res.get("ProductName");
var productPrice=res.get("ProductPrice");
var productQuantity=res.get("ProductQuantity");
console.log("Id is:"+objectId);
console.log("test1"+productName);
console.log("test2"+productPrice);
console.log("test3"+productQuantity);
},
error: function(object, error)
{
console.log("ERROR::"+error.message);
}
});
O / P:
Id是:36iUEFs7YL
test1deal
test21233
test310
答案 0 :(得分:1)
最后我明白了
query.find({
success: function(results) {
console.log(results.length);
// Do something with the returned Parse.Object values
for(i=0;i<results.length;i++)
{
var object = results[i];
productname=object.get('ProductName');
productPrice=object.get('ProductPrice');
productQuantity=object.get('ProductQuantity');
console.log(object.id + ' - ' + object.get('ProductName'));
//document.getElementById("app_name").innerHTML= productname;
console.log(object.id + ' - ' + object.get('ProductPrice'));
//document.getElementById("app_price").innerHTML= productPrice;
console.log(object.id + ' - ' + object.get('ProductQuantity'));
//document.getElementById("app_quantity").innerHTML= productQuantity;
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
O / P:3
36iUEFs7YL - 交易
36iUEFs7YL - 1233
36iUEFs7YL - 10
omU8oo7DOM - 三星
omU8oo7DOM - 12500
omU8oo7DOM - 12
8oegUWDl6W - 想法
8oegUWDl6W - 12