现在我遇到了一些问题,当我尝试自定义我的应用程序时,当用户选择或拍摄图像时,它将保存为数组状态,但当我尝试将其映射回视图时,它没有显示任何内容。
下面是我的一些代码:
state = {
imageSource: []
};下面是我设置状态的方法:
this.setState({
imageSource: this.state.imageSource.concat(source)
});下面是我的view函数:
viewImages(){
this.state.imageSource.map(function(image){
console.log(image);
return(
<View style={[styles.image, styles.imageContainer, {marginBottom: 20}]}>
<Image style={styles.image} source={image} />
</View>
)
});
}这是我的渲染视图
<View style={styles.containerImage}>
{this.viewImages()}
</View最后,这是我从上面的view函数中获得的控制台日志:
Object {uri: "file:///storage/emulated/0/Pictures/image-e23b89ed-83b9-4e10-8912-c96e87aab6f0.jpg", isStatic: true}
Object {uri: "file:///storage/emulated/0/Pictures/image-473d8554-2f53-4870-b94e-03306a17f6e6.jpg", isStatic: true}我哪里搞错了!谢谢。
发布于 2016-04-28 20:34:04
尝试添加return。
return this.state.imageSource.map(function(image){看起来你要扔掉地图了。
https://stackoverflow.com/questions/36904567
复制相似问题