Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 反应本机映像不使用特定URL_Image_Reactjs_React Native - Fatal编程技术网

Image 反应本机映像不使用特定URL

Image 反应本机映像不使用特定URL,image,reactjs,react-native,Image,Reactjs,React Native,我有下面的代码,其中图像组件包含两个图像组件 <View style={styles.container} > <Image style={{width: 50, height: 50}} source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} /> <Image style={{width: 50, height

我有下面的代码,其中图像组件包含两个图像组件

  <View style={styles.container} >
    <Image
      style={{width: 50, height: 50}}
      source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
    />
          <Image
      style={{width: 50, height: 50}}
      source={{uri: 'http://lghttp.24811.nexcesscdn.net/80B00B/qpb/media/catalog/product/cache/11/image/439x334/9df78eab33525d08d6e5fb8d27136e95/q/w/qw_neverdonejoggers_p_.png'}}
    />
  </View>

对于第一个github URL,它按照预期正确呈现img徽标。 但是,对于第二个图像,它不会渲染源:qw_neverdone joggers_p_.png

这让我得出结论,URL有问题,但点击URL正确加载Img:

我试图在这里复制这个问题, 但它可以正确地渲染这两个图像

所以我只能在本地计算机上渲染第二幅图像

使用: “反应”:“15.4.1”,
“react native”:“^0.39.2”,uri仅适用于https。在Android中,它可以与http或https配合使用


你会发现更多的信息。

安德烈斯的回答有些正确,但它没有解决问题的确切原因,那就是iOS的应用程序传输安全。默认情况下,iOS不允许明文请求(http),因此您需要定义URL的“白名单”,允许其覆盖此特定保护机制。您已经设置了该列表,以便您的应用程序可以在开发期间连接到本地主机,所以只需向其中添加新条目即可。你可以看到如何做到这一点。当然,这只有在您事先知道URL列表的情况下才有效,这可能不适合您的需要。在这种情况下,看看。

我是如何通过重置我使用的android emulator使带有http或https url的图像源工作的

您可以通过打开android studio清除模拟器,然后单击顶部栏上的工具选项卡,在打开后选择AVD管理器 选择您正在使用的仿真器,右键单击它,然后选择擦除数据。 完成该过程后,在react原生项目的根目录下打开cmd或terminal
$npx react native run android

我也有类似的问题,但这是一个语法错误,我使用了style={style.img}而不是style={style.img}