【发布时间】:2020-06-09 08:50:17
【问题描述】:
我有一些 json 数据,例如:
[{"timestamp":"2020-03-23T14:00:00.000Z","symbol":"AAL","name":"American Airlines Group","industry":"Industrials","open":10.9,"high":11.36,"low":10.01,"close":10.25,"volumes":55494100},
{"timestamp":"2020-03-22T14:00:00.000Z","symbol":"AAL","name":"American Airlines Group","industry":"Industrials","open":10.6526,"high":12,"low":10.3,"close":10.38,"volumes":62681800},
{"timestamp":"2020-03-19T14:00:00.000Z","symbol":"AAL","name":"American Airlines Group","industry":"Industrials","open":11.6,"high":12.16,"low":10.01,"close":10.29,"volumes":71584500},{"timestamp":"2020-03-18T14:00:00.000Z","symbol":"AAL","name":"American Airlines
我只想获取 0 的索引值:
This one: [{"timestamp":"2020-03-23T14:00:00.000Z","symbol":"AAL","name":"American Airlines Group","industry":"Industrials","open":10.9,"high":11.36,"low":10.01,"close":10.25,"volumes":55494100},{"timestamp":"2020-03-22T14:00:00.000Z",
我的代码:
let movies = state.myListData.map((val) => {
return (
<View key={val.symbol} style={styles.text}>
<Text style={styles.text} key={val.symbol}>
{val.high}
</Text>
<Text style={styles.text} key={val.symbol}>
{val.close}
</Text>
</View>
);
});
现在我得到了所有的值,但我怎样才能只得到值 0?有什么办法吗?
【问题讨论】:
-
使用
Array.splice()方法 -
你能告诉我在我的代码中哪里写吗?我不明白
标签: json reactjs react-native expo