var portfolio = [{ticker: "aa"}, {ticker: "bb"}];var ticker = {ticker:"aa"};var exist = R.find(R.propEq('ticker', ticker), portfolio)console.log(exist)当前,这给了我 undefined ,但是 R.propEq 应该会在我认为的port中通过键ticker找到匹配的对象?Currently this is giving me undefined, however R.propEq should find the matching object by key ticker in port I thought?推荐答案正如您所说,可以通过将密钥传递给 propEq :As you say, you can solve it by passing in the key to propEq:R.find(R.propEq('ticker', 'aa'), port)另一种选择是使用 eqProps 函数,该函数测试两个对象是否匹配命名密钥:Another option is to use the eqProps function, which tests if two objects match for the named key:R.find(R.eqProps('ticker', ticker), port)您可以看到 第一 或 第二 版本.You can see the first or second version in the Ramda REPL. 这篇关于如何使用Ramda通过键值在Array中查找匹配的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 11:34