我正在尝试查询我在 Parse.com 上使用的信息。 我有一组信息,我想使用 containsIn 方法来查询这些信息。
以下是 Parse 中的示例,说明如何使用包含在方法中:
// Finds scores from any of Jonathan, Dario, or Shawn
query.containedIn("playerName", ["Jonathan Walsh", "Dario Wunsch", "Shawn Simon"]);
这是我尝试的方法:
var holdingTheDaysInCurrentMonth = []; //declare array
//for loop to put info inside of it
for(var i = startDateDay; i <=endDateDay; i++) {
var dayInMonth = i.toString();
holdingTheDaysInCurrentMonth.push(dayInMonth);
}
//... code to query Parse
//how I am calling my method
alert(holdingTheDaysInCurrentMonth.toString());
query.containedIn("dayString", [holdingTheDaysInCurrentMonth.toString()]);
在我的警报中,当我单击该月的 1 号和 6 号时,我会收到 1、2、3、4、5、6 的响应(这是预期的)。我没有从查询中检索到任何行,因此查询肯定是错误的。如何更改格式才能正确使用?我做错了什么?
最佳答案
您需要执行以下操作:
query.containedIn("dayString", holdingTheDaysInCurrentMonth);
第二个参数可以是实际的数组,因此不需要将其转换为字符串。
关于javascript - 如何在没有for循环的情况下在JavaScript中显示数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25902263/