简体   繁体   English

React Native-TouchableOpacity和TextInput在ScrollView中不起作用

[英]React Native - TouchableOpacity and TextInput is not working inside ScrollView

I have a ScrollView which has TouchableOpacity and TextInput inside. 我有一个ScrollView ,里面有TouchableOpacityTextInput When I press on them, nothing happens. 当我按它们时,什么也没发生。

I found the solution for TouchableOpacity and it was to add rejectResponderTermination={true} and it worked. 我找到了解决方案TouchableOpacity ,这是增加rejectResponderTermination={true}和它的工作。 For example: 例如:

<TouchableOpacity
   onPress={cameraHandler}
   rejectResponderTermination={true}
>

However this does not work for TextInput. 但是,这不适用于TextInput。

<TextInput       
   onChangeText={updateText}
   value={value.text}
   rejectResponderTermination={true}
/>

I would like to use the functionality of rejectResponderTermination in TextInput . 我想在TextInput使用rejectResponderTermination的功能。 Any suggestions would be much appreciated. 任何建议将不胜感激。

rejectResponderTermination is not a prop of TextInput . rejectResponderTermination不是TextInput Try removing it. 尝试将其删除。

<TextInput       
   onChangeText={updateText}
   value={value.text}
/>

A list of props can be found in the official documentation. 道具列表可以在官方文档中找到。

If you still want the functionality of rejectResponderTermination , currently you would have to build your own. 如果您仍然需要rejectResponderTermination的功能,则当前必须构建自己的功能。 This SlideTextInput is an example of how you would do it. SlideTextInput是如何执行此操作的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM