场景如下:
这里有一个数组,数组里面多个对象,我要拿到数组里面有transCode = ‘02001’的对象里面的key为openDateEnd对应的value值,代码如下
var fundSpecialControlList = [
{
"fundCode":"11111",
"openDateEnd":"20190125",
"state":"1",
"transCode":"02215",
"openDateStart":"",
"transDeadLine":""
},
{
"fundCode":"00111",
"openDateEnd":"20190523",
"state":"1",
"transCode":"02001",
"openDateStart":"20190120",
"transDeadLine":""
}
];
var item;// 先定义一个变量
for(var i =0;i<fundSpecialControlList.length; i++){ // 循环数组
if(fundSpecialControlList[i].transCode =='02001'){ // 判断transCode为‘020001’
item = fundSpecialControlList[i]; // 变量就赋值
break;
}
}
item.openDateEnd // 就是要拿到的数据
有疑问的请在评论去留言哦~
文字为原创,转载请注明出处,谢谢~