我是 React Native 开发新手,正在使用 React Native 开发 Android 应用程序。我有一个个人资料页面,我试图在其中显示姓名和联系方式,如下所示。
return(
<View style={{flex: 1}}>
<ScrollView contentContainerStyle={styles.contentContainer}>
<View style={styles.card}>
<View style={styles.horizontalCard}>
<Image
style={{width: 34, height: 34}}
source={{uri:
'http://test.abc.com/appdummyurl/images/mobile.png'}}
/>
<Text style={styles.header}>{this.state.user_email}</Text>
</View>
<View style={styles.horizontalCard}>
<Image
style={{width: 34, height: 34}}
source={{uri:
'http://test.abc.com/appdummyurl/images/images/profile.png'}}
/>
<Text style={styles.header}>{this.state.user_no}</Text>
</View>
</View>
</ScrollView>
<TouchableOpacity onPress={this.logOut}>
<View style={styles.BottonCard}>
<Text style={styles.Btntext}>LOG OUT</Text>
</View>
</TouchableOpacity>
</View>
);
一切工作正常,除了第一张图像正在加载到第一个图像视图,而第二张图像显示空白区域。请帮我弄清楚。
还请指导我如何在图像网址的位置使用变量。
可能是您的网络速度较慢或您的图像路径不正确或您的服务器问题。您必须在来自谷歌的任何虚拟图像路径上测试此案例。例如使用这个
<Image
style={{width: 100, height: 100}}
source={{uri:
'https://www.planwallpaper.com/static/images/9-credit-1.jpg'
}}/>
将您的 http 更改为 https。模拟器不允许获取 http,只允许获取 https://