簡體   English   中英

反應本機可觸摸不透明度問題

[英]React Native Touchable Opacity Issue

我正在嘗試基於將用戶鏈接到的URL創建按鈕/圖標組件更新圖標圖像。 例如,我有一個電影對象,我想將用戶鏈接到imdb和爛番茄。 我希望該組件在鏈接爛番茄深鏈接時顯示爛番茄圖標,而在鏈接imdb url時顯示imdb圖標。

我正在從數組渲染數據。 例如:

const Movie = [
{ key: 1,
tile: Good Will Hunting
icon1:'./images/imdb.png',
url1: 'http://www.imdb.com/title/tt0119217/?ref_=nv_sr_1',
icon2:'./images/rottentomatoes'
url2: 'https://www.rottentomatoes.com/m/good_will_hunting'

    <View>
     <TouchableOpacity onPress={this._handleOpenWithLinkingUrlOne}>
                  <Image
                    source={require("url one icon")}
                    style={styles.ImageIconStyle}
                  />
                </TouchableOpacity>

       <TouchableOpacity onPress={this._handleOpenWithLinkingUrlTwo}>
                  <Image
                    source={require("url two icon")}
                    style={styles.ImageIconStyle}
                  />
      </TouchableOpacity>
    </View>


    _handleOpenWithLinkingUrlOne = () => {
        Linking.openURL("data from url two");
      };
    _handleOpenWithLinkingUrlTwo = () => {
        Linking.openURL("data from url two");

  };

如何將數據從對象中拉到兩者,以便它呈現數據?

您可以將數據設置為狀態,然后在圖像組件上使用source={{uri: this.state.movie.uri1}}source={{uri: this.state.movie.uri2}}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM