【发布时间】:2016-11-03 08:50:11
【问题描述】:
我正在使用 react-native 0.28.0
我正在尝试根据本教程在 iPhone 模拟器上显示图像:
Introduction to React Native: Building iOS Apps with JavaScript | Appcoda
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()函数中,我添加了这个:
<Image style={styles.image} source={{uri:imageURI}} />
为图像分配的空间在那里,但图像不显示。
但是,如果我改用本地图像,则会显示图像。
var Picture = require('./content.jpeg')
在render()函数中:
<Image source={Picture} style={styles.thumbnail} />
如何使用 URI 作为来源显示图片?
【问题讨论】:
-
和你一样的问题,从你接受的答案中解决了,非常感谢。
标签: ios react-native