2017-09-13 113 views
0

我有一個問題:當我使用react-native-image-progress,react-native-fast-image時看不到圖像。 我想爲listview添加加載圖像。謝謝!!!反應原生android:不可見圖像使用react-native-image-progress

import ProgressBar from 'react-native-progress/CircleSnail'; 
import FastImage from 'react-native-fast-image'; 
import { createImageProgress } from 'react-native-image-progress'; 
const Image = createImageProgress(FastImage); 
    <TouchableNativeFeedback 
     background={TouchableNativeFeedback.SelectableBackground()} 
    > 
     <Image 
       source={{ uri: 'url' }} 
       style={styles.Image} 
       indicator={ProgressBar} 
      /> 
    </TouchableNativeFeedback> 

error Image

+0

是'url' HTTPS? – MattyK14

+0

是的。這是一個鏈接。 –

+0

我的意思是它是https而不是http。 – MattyK14

回答

0

你可以向他們展示之前fetch圖像。你不必爲此使用一個庫。

fetch(url).then(()=> { this.setState({ loading: false }) }); 

<Image source={this.state.loading === true ? require('/path/to/loading.gif') : { uri: url }} /> 
+0

感謝您的幫助。但是我是新成員,:((你能解釋得更好嗎?代碼行位於何處?)(fetch(url).then(()=> {this.setState({loading:false})}); ) –

+0

您可以閱讀更多關於'fetch' [here](https://facebook.github.io/react-native/docs/network.html#using-fetch)和[here](https:// developer。 mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)。基本上你下載的圖像在顯示加載時緩存,然後當你改變它時,它直接從緩存中讀取數據並立即顯示。 – bennygenel

+0

url is this.props.url。我不知道提取網址 –