我想在react-native中为TouchableOpacity
动态生成按钮单击,
我什么都没找到
我想要的只是从函数调用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
);
}
确实,您正在尝试实现什么?可能有更好的方法来做到这一点。