Javascript 如何简洁地使用lodash更新嵌套的对象数组?
下面给我一个非常奇怪的Javascript 如何简洁地使用lodash更新嵌套的对象数组?,javascript,Javascript,下面给我一个非常奇怪的arro,比如[{keys:values},…keys:values]。不理想 它更新了我想要的 它还会分解对象并将其附加到底部 只要尝试使联机键在第一项中的值为1234,即aml_-kyc,因为find是通过引用进行的,所以不需要合并.find(arro,{name:“aml_kyc”}).online=1234-这还不够吗?如果我想更新整个对象或一个或多个键怎么办。顺便看一下屏幕截图。在这种情况下,我会过滤以获取对象,更改,然后向后推。好吧,我想我现在更明白了。因此,
arro
,比如[{keys:values},…keys:values]
。不理想
只要尝试使
联机
键在第一项中的值为1234
,即aml_-kyc
,因为find是通过引用进行的,所以不需要合并.find(arro,{name:“aml_kyc”}).online=1234
-这还不够吗?如果我想更新整个对象或一个或多个键怎么办。顺便看一下屏幕截图。在这种情况下,我会过滤以获取对象,更改,然后向后推。好吧,我想我现在更明白了。因此,\uuu.find()
会对原始数组进行变异。任意顺序。只要尝试获取联机
键,使第一项中的值为1234
,即aml_-kyc
,因为find是通过引用进行的,所以不需要合并.find(arro,{name:“aml_kyc”}).online=1234
-这还不够吗?如果我想更新整个对象或一个或多个键怎么办。顺便看一下屏幕截图。在这种情况下,我会过滤以获取对象,更改,然后向后推。好吧,我想我现在更明白了。因此,\uuu.find()
会对原始数组进行变异。任何命令。
let arro = [
{
"name": "aml_kyc",
"order": 4,
"title": "Complete KYC/AML",
"online": true,
"enabled": true,
"completed": false,
"description": "You must pass anti-money laundering checks."
},
{
"name": "payment_video",
"order": 6,
"title": "Video Payment",
"online": false,
"enabled": true,
"completed": false,
"description": "Optional video production and preparation."
},
{
"name": "conference_call",
"order": 2,
"title": "Origination Call",
"online": false,
"enabled": true,
"completed": false,
"description": "Our team will contact you to arrange this."
},
{
"name": "onboarding_public",
"order": 8,
"title": "Public Onboarding",
"online": true,
"enabled": true,
"completed": false,
"description": "Fill in the information memorandum for public fundraising."
},
{
"name": "onboarding_private",
"order": 7,
"title": "Private Onboarding",
"online": true,
"enabled": true,
"completed": false,
"description": "Fill in key questions to complete the application."
},
{
"name": "payment_onboarding",
"order": 5,
"title": "Onboarding Payment",
"online": false,
"enabled": true,
"completed": false,
"description": "Fee to use our platform services."
},
{
"name": "engagement_documents",
"order": 3,
"title": "Fee and Equity Agreements",
"online": false,
"enabled": true,
"completed": false,
"description": "Our team will arrange this with you."
},
{
"name": "essential_information",
"order": 1,
"title": "Essential Information",
"online": true,
"enabled": true,
"completed": true,
"description": "Executive summary and basic company information."
}
];
console.log(_.merge(_.set(_.find(arro, {name: "aml_kyc"}), 'online', 1234)), arro);