我正在开发一个关于本机的应用程序。当我按下文本输入并且在选择了应该在文本输入上显示的日期之后,我想调用日期选择器
你不能为onPress
明确地调用TextInput
。你只能使用。当你按下输入框将光标放在那里时,将调用onFocus
。无需专注于onBlur,因为您的用例不需要..如果可能,请在onFocus
内处理。
onFocus = () => {
// do something
}
render() {
<TextInput onFocus={onFocus} />
}
你要做的是使用onFocus和TextInput的onBlur。
<TextInput
onFocus={this.onFocus}
onBlur={this.onBlur}
/>
onFocus = () => {
// Open date picker
}
onBlur = () => {
// Close date picker and add value to textinput
}