要將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的文檔進一步定制日歷的樣式和功能。