0
來自網絡的圖像不會始終加載,有時可以加載,有時不會加載。以下是我的渲染方法。圖像不會始終加載來自網絡的原始圖像組件
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對象作爲子項道具傳遞。
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>
);
}
共享代碼是用來設置webDetail –
webDetail好,我總是得到有效的圖片網址,唯一的一點是它呈現的圖像某些時候,有時它不會 – Moniv
您確定圖像url總是在渲染過程開始之前拍攝的。 –