在带有外部链接的映射函数中动态渲染 React 本机图像


let result = this.state.yards.map( yard=> {
return <View><Text style={{color:'black'}}><Text style= 
{{color:'darkslateblue', fontSize:18}}>{yard.name}</Text>{"n"}{yard.coordinates}  {yard.photourl}</Text><Image source={require(yard.photourl)} /></View>
});

yard.photourl 表示在浏览器中工作的正确 URL,但我似乎无法在 this.state.items.map 中动态呈现它

这些链接是公共 aws 链接。

帮助!

根据 React Native 文档,网络映像使用以下语法加载:

<Image source={{uri: 'https://facebook.github.io/react/logo-og.png'}} style={{width: 400, height: 400}} />

请注意,您需要手动指定图像大小。

最新更新