【问题标题】:React Native TextInput phone keyboard submit?React Native TextInput手机键盘提交?
【发布时间】:2016-01-06 20:55:38
【问题描述】:

在 React Native 中使用键盘时,一旦用户点击返回提交文本以表示他们已经在输入中完成了输入,我将如何从键盘返回事件触摸中调用函数?

returnKeyboardClick(){
    //how to call this when user clicks return on keyboard?
}
render(){
    return (
      <View style={styles.container}>
          <TextInput
            style={styles.input}
            onChangeText={this.inputTextEnter}
            placeholder='Type Here'
            placeholderTextColor='#000'
            keyboardType='default'
          />
      </View>
    );
  }

【问题讨论】:

    标签: javascript react-native


    【解决方案1】:

    您应该调用onSubmitEditing 函数。

    myFunction() {
      // do something
    }
    
    <TextInput onSubmitEditing={ () => this.myFunction() } />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-25
      • 1970-01-01
      • 2018-11-08
      • 2019-09-15
      • 2020-11-23
      • 2020-10-23
      • 2018-06-21
      • 2020-05-28
      相关资源
      最近更新 更多