image - 在带有外部链接的地图函数中动态渲染 React Native 图像
问题描述
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}} />
请注意,您需要手动指定图像大小。
推荐阅读
- php - 设置在 php/HTML 中上传文件的大小限制
- php - PHP:二进制数的所有可能版本
- linux - 如何在 shell 脚本中预先提供对 pacaur 的 sudo 访问权限?
- python - 网格中的填充点 - 前向欧拉算法 - 错误输出
- javascript - 如何获取最新的 Billboard 图表作为数据?
- javascript - 是 var flightPlanCoordinates = [{lat: 37.772, lng: -122.214},{lat: 21.291, lng: -157.821}]; 数组还是对象?
- spring - 为什么 Jsp 文件不与 Spring Boot 中的控制器返回视图映射
- android - Android 9:如何通过省电模式和屏幕关闭获取位置
- ios - 带有 AKKeyboardView 的钢琴音符
- api - LinkedIn API:OAuth 请求中使用的令牌已被撤销(Web 社交登录)