import React from 'react';
import { DatePicker } from 'antd';
 
export default class DatePickerFormat extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            formatType: true,
        };
    }
 
   
    componentDidMount() {
       
    }
 
    // 失去焦点
    onChangeTimeBlur = () => {
        this.setState({
            formatType: true
        });
    }
 
    //  获取焦点
    onChangeTimeFocus = () => {
        this.setState({
            formatType: false
        });
    }
 
    render() {
        return (
            <div >
              <DatePicker {...this.props}  format={this.state.formatType?'YYYY-MM-DD':['YYYYMMDD','YYYY-MM-DD']}  onBlur={() => this.onChangeTimeBlur()}  onFocus={() => this.onChangeTimeFocus()}   /> 
            </div>
        );
    }
}