![](/img/trans.png)
[英]Failure parsing JSON FullCalendar when adding events (as a json feed)
[英]fullcalendar failure parsing json when adding eventRender with popper.js
我正在嘗試使用 Google 日歷中的事件將 FullCalender 添加到我的頁面。 當我不包含 eventRender 時,它會顯示事件,但當我單擊它們時會將我帶到 Google 日歷。 當我添加 eventRender 以在將鼠標懸停在事件上時彈出事件信息時,我遇到解析 JSON 錯誤的失敗,並且事件根本不會在日歷上呈現。
這是我使用的代碼(注意 API 密鑰和日歷 ID 是在實際代碼中填寫的):
<script>
document.addEventListener("DOMContentLoaded", function() {
let calendarEl = document.getElementById("calendar");
let calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ["dayGrid", "timeGrid", "list", "interaction", "googleCalendar"],
selectable: true,
googleCalendarApiKey: "<API KEY>",
events: {
googleCalendarId: "<my-calender-id>",
className: "gcalEvent"
},
eventRender: function(eventObj, $el) {
$el.popover({
title: eventObj.title,
content: eventObj.description,
trigger: 'hover',
placement: 'top',
container: 'body'
});
}
});
calendar.render();
});
</script>
我對 HTML 和 StackOverflow 都很陌生,所以如果這不足以解析解決方案,請讓我知道我需要添加什么。
我認為問題在於您收到的內容與應有的結構不匹配。
嘗試:
事件:[{title:'我的事件',開始:'2019-07-07',描述:'這是一個很酷的事件'}],
eventRender: function(info) {
var tooltip = new Tooltip(info.el, {
title: info.event.title,
content: 'asdadasdqweqweqweqweqwasssd',
placement: 'top',
trigger: 'hover',
container: 'body'
});
它對我有用,當我只使用信息時,然后我添加事件標題......只是一個例子。 祝你好運
嘗試:
eventRender: function (info) {
$(info.el).popover({
title: info.event.title,
content: 'asdadasdqweqweqweqweqwasssd',
placement: 'top',
trigger: 'hover',
container: 'body'
});
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.