You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FullCalendar React:如何将timeGridWeek视图设为周一为首日?

解决FullCalendar timeGridWeek视图首日设为周一不生效的问题

问题出在**firstDay是全局配置选项,不能放在单个视图的配置对象中**。你之前把它写在timeGridWeek的子配置里,FullCalendar不会识别这个视图级的firstDay设置,所以日历仍然沿用默认的周日作为首日。

正确配置方式

将firstDay: 1移到FullCalendar的根配置层级,而非视图的子配置中:

import FullCalendar from '@fullcalendar/react';
import timeGridPlugin from '@fullcalendar/timegrid';

export default function MyCalendar() {
  return (
    <FullCalendar
      plugins={[timeGridPlugin]}
      initialView="timeGridWeek"
      // 全局设置每周首日为周一(1代表周一,0代表周日)
      firstDay={1}
      views={{
        timeGridWeek: {
          buttonText: 'Week'
          // 移除这里的firstDay配置
        }
      }}
    />
  );
}

额外注意事项

  • 如果你的日历配置了locale,部分地区的locale默认首日可能会有差异,但全局的firstDay设置会优先覆盖locale的默认值。
  • 确认使用的FullCalendar版本为v5及以上(该版本开始稳定支持firstDay全局配置)。

内容的提问来源于stack exchange,提问作者János

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 05:42:07