本文介绍了无法在React Native中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用本机0.28.0

I'm using react-native 0.28.0

根据该教程,我试图在iPhone模拟器上显示图像: http: //www.appcoda.com/react-native-introduction/

I'm trying to show an image on iPhone simulator according to this tutorial: http://www.appcoda.com/react-native-introduction/

var styles = StyleSheet.create({
image: {
    width: 107,
    height: 165,
    padding: 10
  }
}

var imageURI = 'http://books.google.com/books/content?id=PCDengEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api'

然后在render()函数中,添加以下内容:

Then in the render() function, I add this:

<Image style={styles.image} source={{uri:imageURI}} />

有分配给图像的空间,但是未显示图像.

The space allocated for the image is there, but the image is not shown.

推荐答案

除了乔纳森·斯泰尔瓦格(Jonathan Stellwag)的答案外,第一种解决方案仅在URI使用https或通过设置应用传输安全性的情况下才有效.

In addition to Jonathan Stellwag's answer, the 1st solution only works if the URI is using https, or by setting the App Transport Security.

请参见无法通过React Native iOS模拟器中的URI

这篇关于无法在React Native中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:54