我的数据库中有一些有关大学日程的信息。类的描述与html标签一起存储在数据库中。我想显示这个时间表,但不删除标签,也不将它们显示为文本,而是显示为页面结构。
我的树枝文件中的脚本:
<script src='https://cdn.jsdelivr.net/npm/[email protected]/index.global.min.js'></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'listWeek',
events: {{ data|raw }}
});
calendar.render();
});
</script>
public function getScheduleFromCalendar(LessonRepository $lessonRepository)
{
$groupSchedule = $lessonRepository->findGroupLessons('КН-1-4М');
$lessonsList = [];
foreach ($groupSchedule as $lesson) {
if ($lesson->getLessonContent()) {
$lessonsList[] = [
'start' => $lesson->getLessonStart()->format('Y-m-d H:i:s'),
'end' => $lesson->getLessonEnd()->format('Y-m-d H:i:s'),
'title' => $lesson->getLessonContent(),
];
}
}
$data = json_encode($lessonsList);
return $this->render('schedule/index.html.twig', compact('data'));
}
我该如何解决?谢谢大家!
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'listWeek',
events: {{ data|raw }},
eventContent: function(info) {
return {
html: info.event.extendedProps.content
};
}
});
calendar.render();
});
</script>