如何使用全日历在单元格中设置星期几和月份名称

时间:2018-07-23 09:44:54

标签: javascript fullcalendar

我正在为我的项目使用插件fullcalendar,但是我有一个问题,无法在单元格中显示星期几和月份名称。我该如何解决这个问题?

我期望的结果是: enter image description here

$('.js-fullcalendar').fullCalendar({
    header: {
        right: 'today',
        center: 'prev, title, next',
        left: ''
    },
    navLinks: true,
    editable: true,
    eventLimit: true,
    events: exhibitionList,
    eventColor: '#3279b7',
    columnFormat: 'dddd',
    eventRender: function (event, element) {
        if (event.logo) {
            element.find(".fc-title").prepend("<img class='fcalen__img' src=" + event.logo + ">").append("<span class='fcalen__city'>" + event.city + "</span>");
        }
    }
});

1 个答案:

答案 0 :(得分:1)

我找到了解决方法:

$('.js-fullcalendar').fullCalendar({
  header: {
    right: 'today',
    center: 'prev, title, next',
    left: ''
  },
  navLinks: true,
  editable: true,
  eventLimit: true,
  events: exhibitionList,
  eventColor: '#3279b7',
  columnFormat: 'dddd',
  dayRender: function(date, cell) {
    var weekDay = date.format("dddd");
    var month = date.format("MMMM");
    var day = date.format("D");
    cell.html("<span class='fcalen__week-day'>" + weekDay + "</span>" + "<br>" + "<div class='fcalen__month-name'>" + day + "  " + month + "</div>");
  },
  eventRender: function(event, element) {
    element.find(".fc-title").prepend("<img class='fcalen__img' src=" + event.logo + ">").append("<span> / <span><span class='fcalen__city'>" + event.country + " " + event.city + "</span>");
  }
});