简体   繁体   English

react js 根据键名从 object 获取值

[英]react js get value from object based on key name

my return object looks like this.我的返回 object 看起来像这样。 I would like to extract the value if code==="targetDate".如果 code==="targetDate",我想提取值。 Could someone please help.有人可以帮忙吗。

在此处输入图像描述

Use the JavaScript array find function:使用 JavaScript 数组find function:

const matched = this.props.notifications.data.find(item => item.value === "targetDate");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM