React native 反应本机,渲染按钮并动态单击
我想为react native中的React native 反应本机,渲染按钮并动态单击,react-native,React Native,我想为react native中的TouchableOpacity动态生成一个按钮点击, 我没有发现任何关于这个的东西 我只想从一个函数调用TouchableOpacity onPress(或者在按钮上看到它的效果) 在钛中,我们正在执行$.button.click 我尝试使用动画,但没有运气 有人能帮忙吗?提前感谢这确实是不可取的,但类似的方法应该可以奏效: simulatePress(){ this.touchable.props.onPress(); } render(){ 返回( th
TouchableOpacity
动态生成一个按钮点击,
我没有发现任何关于这个的东西
我只想从一个函数调用TouchableOpacity onPress(或者在按钮上看到它的效果)
在钛中,我们正在执行$.button.click
我尝试使用动画,但没有运气
有人能帮忙吗?提前感谢这确实是不可取的,但类似的方法应该可以奏效:
simulatePress(){
this.touchable.props.onPress();
}
render(){
返回(
this.touchable=component}onPress={()=>console.log('onPress')}>
轻拍我
谢谢,这在调用方法时有效,但在模拟点击效果时无效。我使用animatable解决了问题,并用脉冲替换了不透明度更改…,如果我有两个按钮怎么办?我不同意这是非常不可取的。如果你有一个带有子输入/按钮的组件,它必须使用其父组件属性,但您需要外部控件,这是一个很好的解决方案。
simulatePress() {
this.touchable.props.onPress();
}
render() {
return (
<TouchableOpacity ref={component => this.touchable = component} onPress={() => console.log('onPress')}>
<Text>Tap me</Text>
</TouchableOpacity
);
}