繁体   English   中英

uri图像未在React native Image视图中呈现

[英]uri image is not rendering in React native Image view

我是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>
);

除了第一个图像正在加载到第一个图像视图,第二个图像显示空白处,一切正常。 请帮我弄清楚。

另外,请指导我如何使用变量代替图片网址。

可能是您的网络速度较慢,或者图像路径不正确或服务器问题。 您必须在google的任何虚拟图像路径上测试这种情况。 例如使用这个

<Image
      style={{width: 100, height: 100}}
      source={{uri: 
   'https://www.planwallpaper.com/static/images/9-credit-1.jpg'
    }}/>

另外,如果您正在使用本地文件,则在链接上使用localhost时要格外小心。 模拟器可能会设置一个新的本地主机,这将破坏您的URL。 在这种情况下,您要做的就是用您的LAN ip地址替换“ localhost”一词。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM