![](/img/trans.png)
[英]min and max date not working on formik/material-ui/datepicker component
[英]Min and Max Date in Material UI DatePicker in React
我有一個條件,如果access
值為 1,則選擇日期沒有限制。 但是,如果access
的值不是 1,那么您只能選擇今天。 我的問題是即使access
值為1也不能選擇其他月份,只能選擇當月內。 我怎樣才能解決這個問題?
請在此處查看我的代碼。
<KeyboardDatePicker
minDate={access !== 1 ? new Date() : ""}
maxDate={access !== 1 ? new Date() : ""}
fullWidth
InputLabelProps={{ shrink: true }}
inputVariant="outlined"
id="date-picker-dialog"
label="Select Date"
format="MM/dd/yyyy"
clearable
value={values.start_date}
onChange={(val) => {
setFieldValue("start_date", val);
}}
onBlur={handleBlur}
helperText={touched.start_date ? errors.start_date : ""}
error={touched.start_date && Boolean(errors.start_date)}
TextFieldComponent={TextFieldComponent}
/>;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.