要将FullCalendar与React结合使用,可以通过以下步骤:
npm install @fullcalendar/react @fullcalendar/daygrid @fullcalendar/interaction
import React from 'react';
import FullCalendar from '@fullcalendar/react';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
import '@fullcalendar/core/main.css';
import '@fullcalendar/daygrid/main.css';
const MyCalendar = () => {
return (
<FullCalendar
plugins={[dayGridPlugin, interactionPlugin]}
initialView="dayGridMonth"
events={[
{ title: 'Event 1', date: '2021-01-01' },
{ title: 'Event 2', date: '2021-01-15' },
]}
/>
);
};
export default MyCalendar;
import React from 'react';
import MyCalendar from './MyCalendar';
const App = () => {
return (
<div>
<h1>My Calendar App</h1>
<MyCalendar />
</div>
);
};
export default App;
通过这些步骤,你就可以在React应用中使用FullCalendar并展示日历事件。你还可以根据FullCalendar的文档进一步定制日历的样式和功能。