antd日期選擇框,前後日期增加限制

SimoonJia發表於2024-05-03


  const disabledDateStart = useCallback((current) => {
    if (!contractEndDateValue) {
      return false
    } else {
      return current && current > contractEndDateValue;
    }

  }, [contractEndDateValue])

  const disabledDateEnd = useCallback((current) => {
    if (!contractSignDateValue) {
      return false
    } else {
      return current && current < contractSignDateValue;
    }
  }, [contractSignDateValue])

開始

  <DatePicker format="YYYY-MM-DD" placeholder="請輸入合同簽訂日期" style={{ width: '100%' }} disabledDate={disabledDateStart} />

截止

 <DatePicker format="YYYY-MM-DD" placeholder="請輸入合同有效期" style={{ width: '100%' }} disabledDate={disabledDateEnd} />

相關文章