如何用括号修改fullcalendar columnFormat?

时间:2017-10-20 04:48:21

标签: javascript fullcalendar

我需要像我的客户想要的那样显示10/15 (Sun)!但是,如果我在columnFormat上设置该格式,则无法在括号内显示。如何设置M/D (ddd)columnFormat显示。但是你知道,{ddd}之类的其他内容可以显示在周列



$("#calendar").fullCalendar({
    header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        defaultView: 'agendaWeek',
        views : {
           agendaWeek : {
              columnFormat : "M/D (ddd)"
           }
        }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.6.1/fullcalendar.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.6.1/fullcalendar.min.js"></script>
<div id="calendar"></div>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:2)

在我研究了将近9个小时之后,如果我在每个支架上放[],我就会轻松解决问题! :)

columnFormat : "M/D [(]ddd[)]"   //added => []
//                  ^ ^   ^ ^

答案 1 :(得分:0)

我不确定你是否可以在一天之内添加括号,但我希望以下内容适用于你:

&#13;
&#13;
$("#calendar").fullCalendar({
    header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        defaultView: 'agendaWeek',
        views : {
           agendaWeek : {
              month: 'dddd',    // Sun, Mon,Tue etc
            week: 'dddd, MMM dS', // Fri 10/20
            day: 'dddd, MMM dS'  // Friday 10/20
           }
        }
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.6.1/fullcalendar.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.6.1/fullcalendar.min.js"></script>
<div id="calendar"></div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

试试这个。 columnFormat : "M/D ddd"

当我尝试这样的括号(ddd)时,它没有用。