import React from 'react'; import dayjs from 'dayjs'; import 'dayjs/locale/zh-cn'; import { Calendar, Flex, Radio, Select, theme, Typography } from 'antd'; import type { CalendarProps } from 'antd'; import type { Dayjs } from 'dayjs'; import dayLocaleData from 'dayjs/plugin/localeData'; dayjs.extend(dayLocaleData); const App: React.FC = () => { const { token } = theme.useToken(); const onPanelChange = (value: Dayjs, mode: CalendarProps['mode']) => { console.log(value.format('YYYY-MM-DD'), mode); }; const wrapperStyle: React.CSSProperties = { width: 300, border: `1px solid ${token.colorBorderSecondary}`, borderRadius: token.borderRadiusLG, }; return (
{ const year = value.year(); const month = value.month(); const yearOptions = Array.from({ length: 20 }, (_, i) => { const label = year - 10 + i; return { label, value: label }; }); const monthOptions = value .localeData() .monthsShort() .map((label, index) => ({ label, value: index, })); return (
Custom header onTypeChange(e.target.value)} value={type} > Month Year { const now = value.clone().month(newMonth); onChange(now); }} />
); }} onPanelChange={onPanelChange} />
); }; export default App;