我正在尝试根据我将用户链接到的 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");
};
如何将数据从对象拉到两者,以便呈现数据?