更改 DateRangePicker Reactjs MUI 的默认日期
Change default date of DateRangePicker Reactjs MUI
DateRangePicker 默认显示今天的日期。是否可以将特定日期设置为默认日期。
0
输入文本字段的高度不会随行内变化 css。
<FormControl>
<LocalizationProvider
dateAdapter={AdapterDateFns}
sx={{
BackgroundColor: "red",
}}
>
<DateRangePicker
startText="Start date"
endText="End date"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(startProps, endProps) => (
<React.Fragment>
<TextField
{...startProps}
/>
<Box sx={{ mx: 2 }}> to </Box>
<TextField {...endProps} />
</React.Fragment>
)}
/>
</LocalizationProvider>
</FormControl>
DateRangePicker 组件实际上是用边框突出显示今天的日期,以指示今天的日期。它将突出显示在 value
道具中传递的选定值,其主色为主题背景色 属性。
在此codesandbox中,您可以看到我设置了突出显示的前一个日期的状态。
DateRangePicker 默认显示今天的日期。是否可以将特定日期设置为默认日期。
0
输入文本字段的高度不会随行内变化 css。
<FormControl>
<LocalizationProvider
dateAdapter={AdapterDateFns}
sx={{
BackgroundColor: "red",
}}
>
<DateRangePicker
startText="Start date"
endText="End date"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(startProps, endProps) => (
<React.Fragment>
<TextField
{...startProps}
/>
<Box sx={{ mx: 2 }}> to </Box>
<TextField {...endProps} />
</React.Fragment>
)}
/>
</LocalizationProvider>
</FormControl>
DateRangePicker 组件实际上是用边框突出显示今天的日期,以指示今天的日期。它将突出显示在 value
道具中传递的选定值,其主色为主题背景色 属性。
在此codesandbox中,您可以看到我设置了突出显示的前一个日期的状态。