问题描述
我正在使用 https://github.com/twinssbc/Ionic2-Calendar 制作包含一些事件的日历。 我有一个问题,当我想在 ngOnInit() 的日历上显示一些事件并且我只是在 .ts 文件中创建一些随机事件 [] 时,一切都很好:
events = [
{
id: 1,userId: 2,type: "Type1",title: 'Event 1',startTime: new Date(2021,5,21,12,30,0),endTime: new Date(2021,13,allDay: false
},{
id: 1,userId: 1,type: "Consegna",title: "Consegna domicilio",14,];
this.eventsource = this.events;
这会在正确的时间显示日历上的事件。但是我想从我的 server.ts“storage(mocked events)”加载一些事件,其中我有相同的事件数组,但是当我尝试将它分配给我的事件源时,它显示了这个错误:
core.js:6162 ERROR TypeError: eventStartTime.getFullYear is not a function
at WeekViewComponent.onDataLoaded (ionic2-calendar.js:2359)
at WeekViewComponent.ngOnChanges (ionic2-calendar.js:2227)
at WeekViewComponent.rememberChangeHistoryAndInvokeOnChangesHook (core.js:1520)
at callHook (core.js:2539)
at callHooks (core.js:2506)
at executeCheckHooks (core.js:2438)
at refreshView (core.js:9427)
at refreshEmbeddedViews (core.js:10538)
at refreshView (core.js:9442)
at refreshComponent (core.js:10584)
我不明白为什么,它有相同的 startTime 和 endTime,另一个奇怪的事情是当我在控制台上打印它时,它少了 2 小时。
这就是我所做的:
ngOnInit() {
this.userId = this._jwtStorageService.getID();
this._bookingService.getBookingByUserId(this.userId).subscribe(
bookings => {
this.eventSource = bookings;
})
这些预订在我的 server.ts 文件中:
bookings = [
{id: 1,type: "Ritiro",title: "Ritiro ingombrante",endTime : new Date(2021,allDay: false},{id: 2,];
奇怪的是,在加载 userId = 2 的预订时,它正在打印:
0:
allDay: false
endTime: "2021-06-21T11:30:00.000Z"
id: 1
startTime: "2021-06-21T10:30:00.000Z"
title: "Consegna domicilio"
type: "Consegna"
userId: 2
在哪里可以看到它更改了开始时间和结束时间,为什么会发生这种情况? 有人可以帮我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)