ant-design 设置 DatePicker 默认值
1.代码
render() { const { value } = this.props; return ( <React.Fragment> { value ? <DatePicker value={moment(value, dateFormat)} onChange={this.onChange} /> : <DatePicker onChange={this.onChange} /> } </React.Fragment> ); }
或者
render() { const { value } = this.props; return ( <DatePicker value={value ? moment(value, dateFormat) : undefined} onChange={this.onChange} allowClear /> ); }
.