我现在有
<input type="date" onChange={(input) => { _this.setState({startDate: input})}}/>无论我一直在改变什么(onChange部分ref等etc),startDate显示为未定义,当我console.log我的状态。 我甚至改变了startDate:input startDate:input.value ,它仍然没有奏效。
我尝试过使用很多反应库,比如react-datepicker等等。到目前为止,他们还没有真正为我工作过(我们有很多CSS,并且由于这个问题,他们的CSS被搞砸了)。
I currently have
<input type="date" onChange={(input) => { _this.setState({startDate: input})}}/>No matter what I've been changing around (the onChange part to ref etc etc), startDate shows up as undefined when I console.log my state. I've even changed startDate:input to startDate:input.value and it still hasn't worked.
I tried using many react libraries such as react-datepicker and etc. So far they haven't really been working out for me(We have a ton of CSS and their CSS is messed up due to that issue).
最满意答案
不知道这是什么。
我建议检查input事件的MDN参考 ,以了解它们是什么/如何拦截它们。
请参阅下面的工作示例。
<input type="date" onChange={(event) => this.setState({startDate: event.target.value})}/>Not sure what _this is.
I'd recommend checking out the MDN reference on input events to get an idea of what they are / how to intercept them.
See below for a working example.
<input type="date" onChange={(event) => this.setState({startDate: event.target.value})}/>更多推荐
发布评论