简体   繁体   English

如何在本机反应中检测textInput外部的触摸

[英]How to detect touch outside textInput in react native

I'm make a react native app that require something like this:我正在制作一个需要这样的反应原生应用程序: 在此处输入图像描述

When i click some input, the border of textInput change to orange color, and when click other textInput or every else the screen, it return white like normal, but i don't know how to capture the outside touch of TextInput, how can we do that?当我单击某个输入时,textInput 的边框变为橙色,当单击其他 textInput 或其他所有屏幕时,它返回正常的白色,但我不知道如何捕捉 TextInput 的外部触摸,我们怎么能去做?

You can wrap your View in TouchableWithoutFeedback and call Keyboard.dismiss() as prop.您可以将View包装在TouchableWithoutFeedback中并调用Keyboard.dismiss()作为道具。 Like this:像这样:

import {Keyboard} from 'react-native'
...

return(
    ...
    <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
        <View style={{flex: 1}}>
            <TextInput keyboardType='numeric'/>
        </View>
    </TouchableWithoutFeedback>
)

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

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