为什么Ant设计中`<Input>`没有onchange [英] Why is there no onchange for `&lt;Input&gt;` in Ant design

查看:32
本文介绍了为什么Ant设计中`<Input>`没有onchange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我一定遗漏了一些非常简单的东西,但是为什么 <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 的东西,因为我能够将 onChangeDatePickerhandleChange 一起使用> 下拉;但我想我猜错了

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.

再次重申:

  1. 为什么Ant design标签没有onChange?
  2. 更重要的是,我如何获取 标签的值?
  1. Why is there no onChange for <Input> tag of Ant design?
  2. 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屋!

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