使用HTTPS(SSL)工作的图像源URI,HTTP不起作用(React Native v0.30.0)

Abh*_*hek 3 image react-native

在React-Native版本30中,某些图像未加载.

这是有效的

<Image style={styles.messageImage} 
       source={{uri:'https://facebook.github.io/react/img/logo_og.png'}}/>
Run Code Online (Sandbox Code Playgroud)

这不起作用

<Image style={styles.messageImage} 
       source={{uri:'http://i.imgur.com/lDz3wVn.png'}}/>
Run Code Online (Sandbox Code Playgroud)

看起来带有https链接的图像正在工作,而带http链接的图像不起作用.还有其他人面临这个问题吗?

谢谢.

Aak*_*del 15

  1. 在xcode中打开ios/YourProject.xcodeproj
  2. 打开info.plist作为属性列表
  3. 右键单击App Transport Security Settings> Add Row
  4. 添加Allow Arbitrary Loads Boolean并设置为Yes
  5. 重建你的应用程序.

在此输入图像描述

Xcode默认阻止所有http请求,只允许https请求.因为这是正确的事情.

这是一篇关于App Transport Security的博客文章:https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/