我正在尝试在与 angular 集成的 flatpickr 日历中启用日期。因此,当我尝试推送启用日期对象以启用 flatpickr 的配置选项时,我得到了Argument of type '{ from: string; to: string; }' is not assignable to parameter of type 'string | Date'.
这是配置的代码。flatpickr:-
this.exampleOptions = {
dateFormat: "d.m.Y",
minDate: "today",
maxDate: "",
onChange: function (selectedDates, dateStr) {
// console.log('selected date is ', selectedDates);
console.log('latest selected dates ', dateStr);
this.selectedDate = selectedDates;
this.dateSelected = selectedDates;
console.log('this.dateSelected ', this.dateSelected);
console.log('this.selectedDate ', this.selectedDates);
}
};
在一个函数中,我使用该配置对象来启用日期:-
allAboutDateAndTime(){
if (this.experienceData.dateRangeList != null && this.experienceData.dateRangeList != undefined && this.experienceData.dateRangeList.length > 0) {
this.experienceData.dateRangeList.forEach((date: DateRange) => {
const from = date.startDate.toString();
const to = date.endDate.toString();
const enable = {
from: from,
to: to
};
this.exampleOptions.enable.push(enable); // GETTING ERROR HERE
});
}
这是我得到的错误
Argument of type '{ from: string; to: string; }' is not assignable to parameter of type 'string | Date'. Type '{ from: string; to: string; }' is missing the following properties from type 'Date': toDateString, toTimeString, toLocaleDateString, toLocaleTimeString, and 38 more
我希望它能够启用 flatpickr文档中给出的指定日期