我想为TouchableOpacity
react-native动态生成一个按钮单击,但是我没有找到任何关于此的信息,
我想要的只是从函数调用TouchableOpacity onPress(或在按钮上查看其效果)
在钛合金中,我们正在尝试$ .button.click我尝试使用Animated但没有运气https://facebook.github.io/react-native/docs/animations.html
有人可以帮忙吗?提前致谢
确实不建议这样做,但是这样的方法应该可以工作:
simulatePress() {
this.touchable.props.onPress();
}
render() {
return (
<TouchableOpacity ref={component => this.touchable = component} onPress={() => console.log('onPress')}>
<Text>Tap me</Text>
</TouchableOpacity
);
}
确实,您要达到的目标是什么?可能有更好的方法来做到这一点。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句