来自网络的图片并不总是加载,有时它会加载,有时也不加载.Below是我的渲染方法。
render() {
let {title, image, text, publisher, id, date} = this.props.webDetail;
let dateString = Moment(date).format('dddd, MMMM Do YYYY');
let metaDetail = `${publisher}\n${dateString}`;
return (
<View style={styles.container}>
<ScrollView showsVerticalScrollIndicator={false}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.publisher}>{metaDetail}</Text>
<Image
style={styles.image}
source={{ uri: image }} indicator={Progress}
/>
<Text style={styles.text}>{text}</Text>
{this.renderButton.call(this) }
</ScrollView>
</View>
);
}
图像在Feed对象中传递。当调用父级的触摸事件时,feed对象将作为子项中的props传递。
renderContent(feed) {
let dateString = Moment(feed.date).format('dddd, MMMM Do YYYY');
let metaDetail = `${feed.publisher}\n${dateString}`;
return (
<ScrollView showsVerticalScrollIndicator={false}>
<Text style={styles.title}>{feed.title}</Text>
<Text style={styles.publisher}>{metaDetail}</Text>
<TouchableWithoutFeedback
onPress={this.onPress.bind(this, feed) }>
<Image style={styles.image} key={feed.image} source={{ uri: `${feed.image}?version=outside` }} indicator={Progress} />
</TouchableWithoutFeedback>
<Text numberOfLines={7} style={styles.text}>{feed.description}</Text>
<Share rank={feed.rank}/>
</ScrollView>
);
}
答案 0 :(得分:0)
可能是壁画缓存问题,请尝试通过向图片网址imageUrl + ?"+new Date().getTime()
添加随机数来使网址唯一。
壁画和图像存在各种问题,例如: https://github.com/facebook/react-native/issues/8677