没有映射或任何列表视图反应原生无法访问json数组项

时间:2018-04-24 12:35:17

标签: json react-native react-native-android react-native-ios

{" top_menu":[{" id":1," name":" Menu 1"},{&#34 ; id":2," name":" Menu 2"}]," left_menu":[{" id":1 ,"名称":"菜单1"},{" id":2,"名称":"菜单2&#34 ;},{" id":3," name":" Menu 3"}]} 我有json数组,使用this.setState({ tabScreen: responseJson.top_menu });

解析和设置状态

渲染文本时,我无法访问 {this.state.tabScreen[1].name}等数组元素。

1 个答案:

答案 0 :(得分:0)

请尝试这样,

{this.state.tabScreen['top_menu'][1].name}