如何在react-native中设置Onpress On Textinput

问题描述 投票:-1回答:2

我正在开发一个关于本机的应用程序。当我按下文本输入并且在选择了应该在文本输入上显示的日期之后,我想调用日期选择器

react-native textinput onpress
2个回答
0
投票

你不能为onPress明确地调用TextInput。你只能使用。当你按下输入框将光标放在那里时,将调用onFocus。无需专注于onBlur,因为您的用例不需要..如果可能,请在onFocus内处理。

onFocus = () => {
  // do something
}

render() {
  <TextInput onFocus={onFocus} />
}

0
投票

你要做的是使用onFocus和TextInput的onBlur。

<TextInput 
    onFocus={this.onFocus}
    onBlur={this.onBlur}
/>

onFocus = () => {
 // Open date picker
}

onBlur = () => {
 // Close date picker and add value to textinput
}
© www.soinside.com 2019 - 2024. All rights reserved.