如何通过点击可触摸组件来触发另一个可触摸组件的按下事件? [英] How to trigger another Touchable component's press event by tap a touchable component?

查看:25
本文介绍了如何通过点击可触摸组件来触发另一个可触摸组件的按下事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过点击可触摸组件来触发另一个可触摸组件的按下事件?谢谢!

How to trigger another Touchable component's press event by tap a touchable component? thanks!

示例:-

<TouchableHighlight onPress={this._triggerSecond}>
  <Image
    style={styles.button}
    source={require('./myButton.png')}
  />
</TouchableHighlight>

如果用户点击第一个 TouchableHighlight,那么它应该触发第二个 TouchableHighlight.

If user will tap on first TouchableHighlight then it should trigger second TouchableHighlight.

<TouchableHighlight>
  <Image
    style={styles.button}
    source={require('./myButton.png')}
  />
</TouchableHighlight>

推荐答案

好吧,我猜与其这样想,我猜您可以将其视为另一个调用相同方法的 TouchableHighlight,例如:

Well I guess instead of thinking in that way I guess you can thinking this as just another TouchableHighlight calling the same method such as:

// First one 
<TouchableHighlight onPress={this._method}>
  <Image
    style={styles.button}
    source={require('./myButton.png')}
  />
</TouchableHighlight>

// Second one
<TouchableHighlight onPress={this._method}>
  <Image
    style={styles.button}
    source={require('./myButton.png')}
  />
</TouchableHighlight>

这样,当点击时两个组件将调用相同的方法.

In this way both components when tap are going to invoke to the same method.

这篇关于如何通过点击可触摸组件来触发另一个可触摸组件的按下事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆