我知道 react-native 的 TextInput 有一个 onsubmit 回调函数,但我实际上如何制作提交按钮? [英] I know react-native's TextInput has a onsubmit callback function, but how do i actually make that submit button?

查看:38
本文介绍了我知道 react-native 的 TextInput 有一个 onsubmit 回调函数,但我实际上如何制作提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何呈现此按钮,如果是,它是否会自动绑定到输入字段中的文本?

I'd like to know how to render this button and if so is it autobound to the text in the input field ?

推荐答案

基本上 onSumbitEditing 会在安卓软键盘点击 go 按钮时触发并提供事件,如下例:

Basically onSumbitEditing will trigger and event provided when go button is clicked from android soft keyboard as in below example :

 <TextInput
  style={[styles.zipCode, styles.mainText]}
  returnKeyType='My Custom button'
  onSubmitEditing={(event) => this.updateText( event.nativeEvent.text
   )}/>

在上面的代码片段中:我的操作名称是我的自定义按钮",它将出现在 android 软键盘中,当您按下 updateText 事件时,这就是 onSubmitEditing 的含义

in above code snippet : I have action name is 'My Custom button' which will appera in soft keyboard in android and when you press that the updateText event is tiggered , thats what is the meaning on onSubmitEditing

注意:如果在 android 模拟器中启用物理键盘,则 onSubmitEditing 不会触发任何事件,因为您也不会按下名为我的自定义按钮"的虚拟键

Note : if physical keyboard is enable in android emulator so onSubmitEditing will not tigger any event since you would not be also to press virtual key which is given name as 'My Custom Button'

这篇关于我知道 react-native 的 TextInput 有一个 onsubmit 回调函数,但我实际上如何制作提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆