我尝试使用从Firebase获取的事件填充fullCalendar。
问题是从firebase获取的数据与fullCalendar使用的事件格式不兼容。
总是给我
hastime未定义
错误。我搜索并说它事件的结构有问题,但我仔细检查了结构是好的。
我使用的方法是在事件函数I中使用回调来呈现事件。它看起来像这样:
public static long convertTimeToMillis(BigDecimal time, TimeUnitsType timeUnitsType) {
long timeLong = time.longValue();
switch (timeUnitsType) {
case DAYS:
return TimeUnit.DAYS.toMillis(timeLong);
case HOURS:
return TimeUnit.HOURS.toMillis(timeLong);
case MINUTES:
return TimeUnit.MINUTES.toMillis(timeLong);
default:
return TimeUnit.SECONDS.toMillis(timeLong);
}
}
此处没有events: ( start, end, timezone, callback ) => {
this.db.getAppointments('id').subscribe(snapshot => callback([snapshot.val()]));
}
,'[]'
是包含多个对象的对象。所以它不兼容。
我得到的价值:
snapshot.val()
并且我不需要密钥,因为它将不再满足fullCalendar的结构。 fullCalendar想要一个对象数组,这就是为什么我可以在fullCalendar中实现另一个回调的原因:
{71943808: {…}, 033808341: {…}}
我正在尝试重新排列我的数据,因此我的最终返回数据将是一个对象数组,但它不会起作用 - 同样的错误。
所以现在eventDataTransform:(eventData)=>{
console.log(eventData);
let arrayOfApp=[];
Object.keys(eventData).forEach( key => {
console.log(key);
console.log(eventData[key]);
arrayOfApp.push(eventData[key]);
});
return arrayOfApp;
}
看起来像这样:
arrayofApp
仍然在给我
hastime未定义
有人可以帮忙吗?