我使用的是fullcalendar v6.1.10
const calendarEl = document.querySelector(".custom_event_calendar");
const calendar = new FullCalendar.Calendar(calendarEl, {
locale: 'de',
initialView: "dayGridMonth",
displayEventEnd: true,
slotLabelFormat: {
hour: "numeric",
meridiem: "short",
hour12: true
},
events:[ {
id: '80185814',
start: "2023-12-05T08:00",
end: "2023-12-05T16:00",
title: "Lorem"
}],
});
calendar.render();
当我将 ID 设置为任何事件时,都会呈现没有 id 的事件
我记录了元素,但 id 为空
还会将 id 设置为事件元素作为 html 属性吗?
id
上的event
不是设置HTML id属性。所以你不会在 DOM 中看到它。
calendar.getEventById()
一起使用,通过给定的 id 获取事件。
小演示展示了这一点;
const calendarEl = document.querySelector(".custom_event_calendar");
const calendar = new FullCalendar.Calendar(calendarEl, {
locale: 'de',
initialView: "dayGridMonth",
displayEventEnd: true,
slotLabelFormat: {
hour: "numeric",
meridiem: "short",
hour12: true
},
events:[ {
id: '80185814',
start: "2023-12-05T08:00",
end: "2023-12-05T16:00",
title: "Lorem"
}],
});
calendar.render();
const ev = calendar.getEventById('80185814');
console.log(ev)
<script src='https://cdn.jsdelivr.net/npm/[email protected]/index.global.min.js'></script>
<div class='custom_event_calendar'></div>