Javascript 如何仅禁用预览月份的日期

Javascript 如何仅禁用预览月份的日期,javascript,jquery,fullcalendar,momentjs,fullcalendar-3,Javascript,Jquery,Fullcalendar,Momentjs,Fullcalendar 3,我有一个简单的部分,其中我使用完整的日历API为我的用户显示日历,我只想禁用上个月的日期 JSFIDLE 预期结果 以下是我迄今为止使用完整日历文档所做的尝试 HTML JS $(“#日历”).fullCalendar({ 标题:{ 左:“上一个,下一个今天”, 中心:'标题', 右图:“月,agendaWeek,agendaDay” }, 是的, 选择允许:功能(选择信息){ console.log(selectInfo); return moment().diff(selectInfo

我有一个简单的部分,其中我使用完整的日历API为我的用户显示日历,我只想禁用上个月的日期

JSFIDLE

预期结果

以下是我迄今为止使用完整日历文档所做的尝试 HTML


JS

$(“#日历”).fullCalendar({
标题:{
左:“上一个,下一个今天”,
中心:'标题',
右图:“月,agendaWeek,agendaDay”
},
是的,
选择允许:功能(选择信息){
console.log(selectInfo);

return moment().diff(selectInfo.start)您可以轻松使用momentJS查找当前月份的开始日期,并将所选日期与该日期进行比较

selectAllow: function(selectInfo) {
  var ms = moment().startOf("month");
  return ms.isSameOrBefore(selectInfo.start);
}
演示:


有关更多信息,请参阅。

如果您不想在比当前日期短的天数添加计划,则可以按如下方式编码:

selectable: true,
selectAllow: function(selectInfo) {
  var ms = moment(new Date()).subtract(1, 'day');
  return ms.isSameOrBefore(selectInfo.start);
},

到目前为止,你能添加一个提琴来演示你的代码吗?@RachelGallen addedit正在工作我会接受你的答案,那么在react中可以使用这个方法吗?我对react一无所知,但我不明白为什么不能。只要momentJS被加载,它就应该工作。你的方法只适用于旧版本,例如@user9964622,原始代码使用的是fullCalendar 3,所以我为FullCalendar3回答。为不同版本给出答案的意义是什么?P.S.我没有使用viewRender,这是另一个答案(这是错误的)。
selectAllow: function(selectInfo) {
  var ms = moment().startOf("month");
  return ms.isSameOrBefore(selectInfo.start);
}
selectable: true,
selectAllow: function(selectInfo) {
  var ms = moment(new Date()).subtract(1, 'day');
  return ms.isSameOrBefore(selectInfo.start);
},