为什么蚂蚁设计中的< Input>没有不变 [英] Why is there no onchange for `<Input>` in Ant design

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

问题描述

我知道我必须缺少一些非常简单的东西,但是为什么Ant design<Input>标签没有onChange?

I know I must be missing something very simple but why is there no onChange for <Input> tag of Ant design?

我想要更新输入的值.

我假设有类似onChange的东西,因为我可以将onChangeDatePickerhandleChange DropDown一起使用;但我想我以为是错误的

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<Input>标签没有onChange?
  2. 更重要的是,如何获取<Input>标签的值?
  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})
}

这篇关于为什么蚂蚁设计中的&lt; Input&gt;没有不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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