我使用的是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}} />
为图像分配的空间在那里,但图像未显示.
但是,如果我使用本 map 像,则会显示图像.
var Picture = require('./content.jpeg')
在render()
功能中:
<Image source={Picture} style={styles.thumbnail} />
如何使用URI作为源显示图片?