Javascript 在Litepicker中禁用过去几天

Javascript 在Litepicker中禁用过去几天,javascript,datepicker,Javascript,Datepicker,我正在使用Litepicker: 如何禁用日历中的过去几天?例如,如果今天是第七天,我需要禁用单击,颜色必须是过去几天(第六天、第五天等)的灰色。Litepicker文档: 为选择禁用天数。Can包含范围为: 例如:['2019-01-01','2019-01-10','2019-01-31']。可以包含日期对象或Unix时间戳(毫秒)或字符串(必须等于选项lockDaysFormat)。 选项锁定日期的默认“YYYY-MM-DD”日期格式 使用moment.js获取今天的日期,减去一天,然后使

我正在使用Litepicker: 如何禁用日历中的过去几天?例如,如果今天是第七天,我需要禁用单击,颜色必须是过去几天(第六天、第五天等)的灰色。

Litepicker文档:

为选择禁用天数。Can包含范围为: 例如:['2019-01-01','2019-01-10','2019-01-31']。可以包含日期对象或Unix时间戳(毫秒)或字符串(必须等于选项lockDaysFormat)。 选项锁定日期的默认“YYYY-MM-DD”日期格式

使用moment.js获取今天的日期,减去一天,然后使用过去的艺术日期设置方式。如果使用“setMin”日期,您可以使用它,否则它仍然有效

例如

let format = 'YYYY-MM-DD'; //<-- Change this to the date format your using for your project, otherwise this doesn't matter keep it the same.
let today = moment(); //Gets today's date in a moment object
today.subtract(1,'days').format(format); //Subtract a day, then format to whatever your 'lockDaysFormat' string is.
const disallowedDates = [['2001-01-01', today]]//Make a 2D array with those those variables.

//Put in your litepicker settings..
new Litepicker({
  element: document.getElementById('datepicker'),
  singleMode: false,
  lockDaysFormat:format, //<-- Format used above with moment
  lockDays:disallowedDates, //<-- Disable dates
})


let格式='YYYY-MM-DD'//非常感谢你!帮了大忙!!!:)