我有一个注册表单,需要输入日期。
我的日期输入框的代码如下:
birthDate: new Date(),
this.handleSubmit = this.handleSubmit.bind(this);
this.handledChange = this.handledChange.bind(this);
handledChange(date) {
this.setState({
birthDate: date
});
}
<ControlLabel>Date de naissance</ControlLabel>
<FormGroup controlId="birthDate" bsSize="large">
<FormControl
autoFocus
type="date"
value={this.state.birthDate}
onChange={this.handledChange}
/>
</FormGroup>
当我提交表单时,控制台上输出的日期是
undefined
。我希望它以YYYY-MM-DD
的格式显示。请问我该怎么解决?