Reactjs 如果使用外部uri,则不在react natives flatlist中呈现图像
我刚刚将我的ListView迁移到更快的平面列表,目前遇到了一个问题,即带有外部uri的图像无法呈现。如果我使用require('localUri'),一切正常 1) URL是https 2) 我看到灰色矩形(图像样式)被渲染 3) 使用带有require(localImagePath)的本地映像正在工作 4) 如果我在浏览器上请求,imageUrlThumb是有效的Reactjs 如果使用外部uri,则不在react natives flatlist中呈现图像,reactjs,react-native,Reactjs,React Native,我刚刚将我的ListView迁移到更快的平面列表,目前遇到了一个问题,即带有外部uri的图像无法呈现。如果我使用require('localUri'),一切正常 1) URL是https 2) 我看到灰色矩形(图像样式)被渲染 3) 使用带有require(localImagePath)的本地映像正在工作 4) 如果我在浏览器上请求,imageUrlThumb是有效的 <FlatList data={this.props.items} keyExtractor={(item, index
<FlatList
data={this.props.items}
keyExtractor={(item, index) => index}
numColumns={3}
renderItem={rowData => {
return (
<Image
style={{
width: size,
height: size,
margin: 2,
borderWidth: 1,
borderColor: "#eee"
}}
source={{ uri: rowData.imageUrlThumb, cache: "force-cache" }}
resizeMode="contain"
/>
);
}}
/>;
index}
numColumns={3}
renderItem={rowData=>{
返回(
);
}}
/>;
如果有人能帮我,那就太好了
致意
凯
环境:
OS:macOS High Sierra 10.13
节点:6.11.0
纱线:1.2.1
净现值:5.4.2
看守员:4.9.0
软件包:(需要=>已安装)
反应:16.0.0-beta.5=>16.0.0-beta.5
react native:=>在这行中:
source={{uri: rowData.imageUrlThumb, cache: 'force-cache'}}
rowData.imageUrlThumb
未定义
renderItem
中存在语法错误
根据平面列表数据结构,您必须在渲染中调用
rowData.item
,或者在renderItem={({item})=>{
中使用花括号,以表示您将在rowData
对象中使用item
。也就是说,使用(rowData)=>rowData.item
,或者使用({item}=>item
啊!谢谢!FastList在其迭代项中有一个新的数据结构。你的答案不完全正确。我可以使用没有花括号的rowData,但我必须在渲染中调用rowData.item。如果我只想对该项进行排序,我必须使用(rowData)=>rowData.item或({item})=>项目:)所以请更新您的答案,然后我可以标记为肯定。非常感谢much@KayEs刚刚更新了我的答案。现在检查它是否正确。:)