FullCalendar如何移除resourceTimelineYear视图表头的00 Uhr字样?
解决FullCalendar resourceTimelineYear表头“00 Uhr”移除问题
问题说明
使用FullCalendar的resourceTimelineYear视图时,表头始终显示“00 Uhr”字样;若移除slotDuration: { hours: 24 }配置,视图仅显示月份,无法满足需求。
解决方案
在resourceTimelineYear的视图配置中添加slotLabelFormat,自定义表头的日期格式,隐藏时间部分即可:
修改后的完整配置代码:
<FullCalendar ref={ref} resources={res} viewClassNames='zd' scrollTime={milliseconds - 86400000} // @ts-ignore events={query} schedulerLicenseKey="0487410008-fcs-16832974662" plugins={[ resourceTimelinePlugin, interactionPlugin, dayGrid, scrollGrid ]} initialView='resourceTimelineYear' allDayContent={(el) => console.log(el)} views={{ resourceTimelineYear: { duration: { years: 2 }, slotDuration: { hours: 24 }, // 新增配置:自定义表头格式,仅显示日期维度,隐藏时间 slotLabelFormat: { year: 'numeric', month: '2-digit', day: '2-digit' } }, }} locale='de' />
补充说明
- 若需要更简洁的表头格式(比如仅显示月份+日期),可调整
slotLabelFormat的参数,示例:slotLabelFormat: { month: 'short', day: 'numeric' } - 由于配置了德语locale(
locale='de'),FullCalendar会自动适配德语的日期显示规则,无需额外处理语言字符串。
内容的提问来源于stack exchange,提问作者oemer ok
相关产品推荐
相关产品推荐

