当我打开然后关闭 Flatpickr 实例而不选择日期时,它会将其设置为今天的日期。如何防止这种行为?当用户未设置时,我需要日期输入保持为空。
Flatpickr 实例用 React-Flatpickr 包装。
<Flatpickr
ref={fpStartDate}
className='th-input-container__input'
value={startDate}
onClose={(selectedDates, dateStr, instance) => {
if (selectedDates.length > 0) {
setInputValue(1);
setCurrentPage(1);
setStartDate(selectedDates[0]);
}
}}
options={{
enableTime: true,
enableSeconds: true,
dateFormat: 'd.m.Y, H:i:S',
locale: Russian,
mode: 'single',
time_24hr: true,
minuteIncrement: 1,
allowInput: true,
disableMobile: true,
monthSelectorType: 'dropdown',
onOpen: function(selectedDates, dateStr, instance) {
setTimeout(function() {
instance.open();
}, 200);
}
}}
placeholder='from'
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
347 次 |
| 最近记录: |