image - unable to load image in react native
问题描述
I want to load the image from a specific URL ['https://gym.weybee.in/files/ProfilePicture']
where ProfilePicture is a variable name which contains the name of the image.
variable declared as => let ProfilePicture = this.props.navigation.getParam("myJSON5");
[myJSON5 contain the name of the image for particular user]
this is my code
const {goBack} = this.props.navigation;
let ProfilePicture = this.props.navigation.getParam("myJSON5");
//myJSON5 contain name of image
return (
<Block flex style={styles.profile}>
<Block flex>
<ImageBackground
source={Images.ProfileBackground}
style={styles.profileContainer}
imageStyle={styles.profileBackground}
>
<ScrollView
showsVerticalScrollIndicator={false}
style={{ width, marginTop: '17%' }}
>
<Block flex style={styles.profileCard}>
<Block middle style={styles.avatarContainer}>
<Image
source={{uri: 'https://gym.weybee.in/files/ProfilePicture'}}
//all images are here =>> https://gym.weybee.in/files/
style={styles.avatar}
/>
<Image
source={{ uri: fitness.png }}
style={styles.avatar}
/>
</Block>
Error
there is no error but the image is not load
** another query**
how can show an error message if the image is not loaded?
解决方案
you didn't connect the uri string correctly, try this:
source={{uri: `https://gym.weybee.in/files/${ProfilePicture}`}}
推荐阅读
- html - 随着屏幕尺寸变小,如何每行显示 3 个 div
- python - 当 python 脚本崩溃时,csv writer 留下空的输出文件
- wpf - UWP BarcodeScanner DataRecieved 事件未在 WPF 应用程序中触发
- r - 在已绘制的地图上添加传单 R 上的圆形标记
- arrays - 如何从c中的字符串数组中删除重复的字符串
- google-app-engine - 通过从 AppEngine 部署的应用程序从谷歌分析中提取数据时出现 500 错误
- css - react-jss 复杂的条件样式
- javascript - 网站的 javascript 适用于 android、windows、linux 和所有浏览器,但不适用于 mac、ios 在任何浏览器上
- c# - 实时数据库 Firebase 中的 startAfter()
- python-3.x - 将带有 NAT(null) 的日期列从熊猫保存到镶木地板