如果要查找满足特定条件的一个或多个对象,可以使用
query-js
//will return all elements with an id larger than 1
data.items.where(function(e){return e.id > 1;});
//will return the first element with an id larger than 1
data.items.first(function(e){return e.id > 1;});
//will return the first element with an id larger than 1
//or the second argument if non are found
data.items.first(function(e){return e.id > 1;},{id:-1,name:""});
还有一个
single
和A
singleOrDefault
他们的工作方式很像
first
和
firstOrDefault
分别是。唯一的区别是如果
更多
找到多个匹配项。
有关查询JS的进一步解释,您可以从这里开始
post