在 HTML 文件中,使用 header
属性并创建自定义标题,指定日期的格式。例如:
在 TypeScript 文件中,使用 header
属性和 moment.js 库,指定日期的自定义格式。例如:
import * as moment from 'moment';
calendarOptions: Options = {
// other options
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay',
},
views: {
week: {
titleFormat: 'MMMM D YYYY',
columnFormat: 'ddd M/D',
// other views
}
},
dayRender: function (date, cell) {
cell.css('background-color', 'red');
},
defaultDate: moment(),
editable: true,
events: [
// events
]
};
在上面的代码示例中,将 calendarOptions
对象中的 views
属性指定为视图,然后使用 titleFormat
和 columnFormat
属性指定日期的格式。使用 dayRender
属性将单元格背景色指定为红色。最后,使用 moment()
方法将 defaultDate
属性设置为当前日期。