【问题标题】:Keyboard Hiding in react-nativereact-native 中的键盘隐藏
【发布时间】:2017-07-29 01:53:29
【问题描述】:

我只是按照链接react-native: hide keyboard的答案

但是键盘会在几秒钟内闪烁,然后消失。有没有办法完全避免键盘。

【问题讨论】:

标签: javascript android ios reactjs react-native


【解决方案1】:

This 帮助了我:

import { Keyboard } from 'react-native'

// Hide that keyboard!
Keyboard.dismiss();

【讨论】:

    【解决方案2】:

    正确的方法是使用 TouchableWithoutFeedback 关闭 View 并调用 Keyboard.dismiss()

    import {Keyboard} from 'react-native'
    
    <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
       <View style={styles.container}>
          <TextInput keyboardType='numeric'/>
       </View>
    </TouchableWithoutFeedback>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-14
      • 2020-05-28
      • 2020-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多