我正在尝试在焦点时修改图像源。这就是我填充注释数组的方式,您可以看到我的onFocus
事件,我尝试将注释重新设置为新图像。我试图在注释打开之前不加载图像。
for(i = 0; i < data.length; i++){
this.state.annotations.push({
longitude: Number(data[i].lng),
latitude: Number(data[i].lat),
title: data[i].loc_str,
focused: false,
onFocus: () => {
this.state.annotations[i].detailCalloutView =
<Image
source={{uri: "http://i.imgur.com/6zc8Apn.jpg", cache: 'force-cache'}}
style={styles.thumbnail}
resizeMode={Image.resizeMode.contain}
/>
},
detailCalloutView:
<Image
source={require('./placeholder.png')}
style={styles.thumbnail}
resizeMode={Image.resizeMode.contain}
/>,
})
}
this.setState({
annotations: this.state.annotations,
});
错误:
undefined不是对象(评估'data [i] .img_url')