<TouchableHighlight onPress={this._onPress.bind(this)}>
<Text style={{color: 'white'}}>CLOSE</Text>
</TouchableHighlight>
_onPress(e) {
console.log(e.nativeEvent.target);
}
如上所述,target
只是一个称为节点ID的数字,但我想获取真实的元素。我怎样才能做到这一点?
代码来执行它最近改变了反应,和/阵营本地常见的代码时,被搬来搬去,但我的建议是检查Inspector
代码并提供方法上ReactNativeComponentTree
更具体地说,以下代码将为您解决问题:
var ReactNativeComponentTree = require('react/lib/ReactNativeComponentTree');
ReactNativeComponentTree.getInstanceFromNode(nativeTag);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句