【发布时间】:2020-05-03 07:36:58
【问题描述】:
当我打开然后关闭 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'
/>
【问题讨论】: