如何在fullcalendar事件中插入自定义数据?

时间:2019-07-26 06:53:48

标签: javascript fullcalendar fullcalendar-4

如何在我的全日历对象中包含自定义数据并在eventClick期间访问它们?

我的代码示例:

event: [
  {
    penCount: "2",
    title: "Pens",
    start: date[0]
  },
  {
    penCount: "6",
    title: "Pens",
    start: date[1]
  }
]

在事件点击期间:

eventClick: function(info) {
    alert(info.event.penCount);
}

警报显示undefined,而不是我期望的值。我做错了吗?

2 个答案:

答案 0 :(得分:1)

已通过在extendedProps对象之后添加info.event来解决

eventClick: function(info) {
    alert(info.event.extendedProps.penCount);
}

答案 1 :(得分:0)

由于event是一个数组,因此您需要放置要访问的对象的索引。
例如:info.event[i].penCount

相关问题