我成功地使用了flatpickr作为我最喜欢的日期选择器,但现在我必须使"defaultDate“输入具有条件。
if(defDateExists){
defaultDate: ucheckout,
}这破坏了我的功能。我不知道如何有条件地使用选项。请帮帮忙。谢谢!
function _flattie() {
const fpx = flatpickr(".flatpickr", {
minDate: new Date().fp_incr(1), // 1 days from now
dateFormat: "Y-m-d",
disableMobile: "true",
if(defDateExists){
defaultDate: checkout,
}
monthSelectorType: "static",
inline: true,
onChange: function() {
selectedDate = new Date(tempDate).toString("yyyy-MM-dd");
stringDate = new Date(tempDate).toString("MMM dS yyyy");
}
}
});
}发布于 2021-08-12 12:57:31
function _flattie() {
const fpx = flatpickr(".flatpickr", {
minDate: new Date().fp_incr(1), // 1 days from now
dateFormat: "Y-m-d",
disableMobile: "true",
defaultDate: defDateExists ? checkout : null,
monthSelectorType: "static",
inline: true,
onChange: function() {
selectedDate = new Date(tempDate).toString("yyyy-MM-dd");
stringDate = new Date(tempDate).toString("MMM dS yyyy");
}
}
});}https://stackoverflow.com/questions/68757786
复制相似问题