【发布时间】:2023-03-18 10:35:02
【问题描述】:
我能够获取 JSON 数据,它现在返回一个数组。如何在本机反应中使用数组中的元素?以下是我的尝试:
export default function display() {
const fetching = async() => ... //defines fetching() which returns the array
...
return (
<View>
<Image
source = {{uri: 'http://imageURI.' + fetching().then((arr) => {return arr[0]}) + '.png'}}
style = {{height: 50, width: 50, borderRadius: 50}} />
</View>
)
}
如何访问数组中的元素?
【问题讨论】:
-
你能把你的
fetchingmehtod 的完整代码贴出来吗?
标签: javascript reactjs react-native fetch async.js