为什么Ant设计中`<Input>`没有onchange [英] Why is there no onchange for `<Input>` in Ant design
问题描述
我知道我一定遗漏了一些非常简单的东西,但是为什么 <Input>
的 Ant design
标签没有 onChange
?
I know I must be missing something very simple but why is there no onChange
for <Input>
tag of Ant design
?
我想更新输入的值.
我假设有类似 onChange
的东西,因为我能够将 onChange
与 DatePicker
和 handleChange
一起使用> 下拉
;但我想我猜错了
I assumed there was something like an onChange
, since I was able to use onChange
with DatePicker
and handleChange
DropDown
; but I guess I assumed wrong
当我查看文档时,有一个 onPressEnter
回调,但这并没有真正帮助我.
When I looked at the docs, there is a onPressEnter
callback, but that is not really going to help me.
我尝试了以下方法:
<Input
placeholder="Flight name"
size="large"
value={this.state.someVal}
/>
但这只是给了我一个我无法输入的输入.
But this just gave me an input that I could not type in.
再次重申:
- 为什么
Ant design
的标签没有
onChange
? - 更重要的是,我如何获取
标签的值?
- Why is there no
onChange
for<Input>
tag ofAnt design
? - More importantly, how do I get the value of the
<Input>
tag?
谢谢.
推荐答案
可以使用onChange
,为什么不可以?
You can use onChange
, why not?
<Input
placeholder="Flight name"
size="large"
value={this.state.someVal || ''}
onChange={this.onChange}
/>
onChange = (e) => {
this.setState({someVal: e.target.value})
}
这篇关于为什么Ant设计中`<Input>`没有onchange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!