[英]Flatlist won't show images from json (React Native)
您的代码中有2个问题:
require
而不是{ uri: '' }
require
您不能将变量作为路径传递,因此您只需要传递文字字符串。 因此,替换颜色数组中的每条路径线以包括require
例:
{
id: 1,
path: require('../../assets/character-customs/albert/colors/c1.png'),
}
与此同时更新Image
组件行
<Image style={styles.images} source={item.path} />
这应该为你工作
对我来说,flatlist将所有数据包装在项目中,因此这为我解决了问题
<Image source={{uri:item.path}}/>
如果这不起作用,请尝试从renderitem方法记录项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.