0
我有一個問題。我在Image中使用onLoad,onLoadStart和onLoadEnd。我想等服務器獲取響應鏈接圖像並顯示圖像時,添加加載。但它不斷地猛拉。反應本機檢測加載圖像
constructor (props) {
super(props)
this.state = {loading: true}}
return(
<Image
onLoad={(e) => this.setState({loading: true})}
onError={(e) => this.setState({loading: false})}
onLoadStart={(e) => this.setState({loading: false})}
source={this.state.loading ? require('../../img/loading.gif') : {
uri: getBestUrl(artwork)}}
style={styles.artworkImage}
resizeMode={Image.resizeMode.cover}
/>)
感謝您的想法。我只是添加了我的代碼。你可以看看。我沒有做過一個例子 –