[英]How to access an element in an object Javascript?
The following is the object 以下是对象
Object {
"index": 0,
"item": Object {
"-1509965540253": "Hey Blade Runner!!",
"fName": "Gaston Day Public School",
"fromName": "Gaston Day Public School",
"message": "HEy ! Full metal jacket !",
"time": -1509967894467,
},
"separators": Object {
"highlight": [Function highlight],
"unhighlight": [Function unhighlight],
"updateProps": [Function updateProps],
},
}
I want to access fromName
in the following function 我想在以下函数中访问
fromName
renderInboxList= (item) =>{
console.log("FromName",item.fromName);
return (
<TouchableOpacity key={item.fromId} onPress={() => {console.log("TOmoving to chat thread");navigate('ChatThread', { fromId: `${l.fromId}` });}}>
<ListItem
key={item.fromId}
leftIcon={{ name: 'user-circle-o', type: 'font-awesome', style: {color: 'blue'} }}
title={item.fromName}
titleStyle={{color: 'red'}}
subtitle={item.message}
rightTitle={item.time}
rightTitleStyle={{color: 'green'}}
/>
</TouchableOpacity>);
}
The item.fromName
gives me undefined
. item.fromName
给了我undefined
。
只需使用此:
var fromName = item.item.fromName;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.