首页 > 解决方案 > 我想从包含图像的链接/网址的数组中返回平面列表中的图像 react-native

问题描述

我想返回 flatlists 中的图像。首先这个数组 qwer[] 包含 url 链接图像 init 它甚至 console.logs 它从 api 获取链接。我已经手动尝试将图像放入带有源的 View 标记中,它可以工作。但是当我使用平面列表时,它没有显示错误但不显示图像。你能帮帮我吗?

return(
    <FlatList 
    horizontal
    showsHorizontalScrollIndicator={false}
    data={qwer}
    renderItem={({ item }) => (
        <Image 
            source={({uri:item})}
            style={{
                width:260,
                height:300,
                borderWidth:2,
                borderColor:'#d35647',
                resizeMode:'contain',
                margin:8
            }}
        />
    )}
/>

标签: javascriptreactjsimagereact-native

解决方案


在您的代码中只需替换

 source={({uri:item})}

source={{uri : item}}

推荐阅读