Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在 React 中构建日历组件,但不使用任何库,但Day.js.
Day.js
我需要检测该月的第一个工作日以便留下如图所示的间隙。否则每个月的第一天必须是星期日。如何检测给定日期的第一个工作日?
Day.js 有内置函数来实现这一点
dayjs().startOf("month").day()
此方法以数字形式返回当前月份的第一周。
0 = 星期日,6 = 星期六