react+antd中DatePicker组件(不能选中当前时间以前的时间)的代码

不能选中当前时间以前的时间:即不能选中此刻之前的时间,比如此刻是2018年10月11日15:18,那么2018年10月11日15:18分之前的所有时间都不能选,包含时分。 

const { DatePicker, Row } = antd;
class limitTime extends Component{
    state={
           currentTime:null,
    }
    render(){
        
                             disabledDate={this.disabledEndDate}
                showTime={{ format: 'HH:mm' }}
                format="YYYY-MM-DD HH:mm"
                onOpenChange={this.handleEndOpenChange}
                />
        

    }
    disabledEndDate = (endValue) => {
        let me = this;
        const startValue = this.state.currentTime;    
        if (!endValue || !startValue) {
          return false;
        }
        return endValue.valueOf() <= startValue.valueOf();
    }
    handleEndOpenChange = (open) => {
        let me = this
        if(open){
            me.currentTime = moment();
        }
        this.setState({currentTime:moment() });
    }
    componentDidMount(){
    
    }
    componentDidUpdate(){
 
    }
    componentWillUnmount(){
 
    }
}
原文:https://blog.csdn.net/weixin_41077029/article/details/83012921 

你可能感兴趣的:(antd,design)