也許嘗試讀取所有的鏈接您發佈的文檔?具體看一下例子:
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
_.result(_.find(users, function(chr) {
return chr.age < 40;
}), 'user');
// => 'barney'
// using the `_.matches` callback shorthand
_.result(_.find(users, { 'age': 1, 'active': true }), 'user');
// => 'pebbles'
// using the `_.matchesProperty` callback shorthand
_.result(_.find(users, 'active', false), 'user');
// => 'fred'
// using the `_.property` callback shorthand
_.result(_.find(users, 'active'), 'user');
// => 'barney'
我相信第二個例子,使用_.matches
回調速記
回答你的問題說
//。
正在尋找一個對象,其中屬性'id'與'id'變量相同。 – Li357
是屬性或變量表達式中的第一個id嗎? – SDH