React Native TextInput手机键盘提交?

时间:2016-01-06 08:57:13

标签: javascript react-native

在使用键盘的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>
    );
  }

1 个答案:

答案 0 :(得分:8)

您应该调用onSubmitEditing函数。

myFunction() {
  // do something
}

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