首页 > 解决方案 > 如何将标题设置为在完整日历中仅显示月份名称

问题描述

如何将完整日历标题设置为仅显示月份名称而不是“月份名称年份名称”?

我的代码:

$('#calendar').fullCalendar({
    header: {
        left: 'prev',
        center: 'title',
        right: 'next'
    },
    titleFormat: {
        month: 'MMMM'                // Tuesday, Sep 8, 2009
    },
    height: 'parent'
});

使用上面的代码不起作用,它在 console.log 上显示一些 js 错误

moment.min.js?ver=2.22.2:1 Uncaught TypeError: e.toUpperCase is not a function

该消息从 moment.min.js 文件中显示。

有什么我错了吗?

标签: javascriptjquery

解决方案


您没有定义显示月份名称的视图。检查代码

$('#calendar').fullCalendar({
    header: {
        left: 'prev',
        center: 'title',
        right: 'next'
    },
    // Block should be like this
    views: {
      week: {
        titleFormat: 'MMMM',
      },
      month: {
        titleFormat: 'MMMM',
      }
    },
    height: 'parent'
});

有关更多信息,请查看文档

希望它可以帮助你:)


推荐阅读