Javascript Angular6-仅在Safari中出错--TypeError undefined不是对象

Javascript Angular6-仅在Safari中出错--TypeError undefined不是对象,javascript,angular,typescript,angular6,Javascript,Angular,Typescript,Angular6,这只发生在Safari中,我已经追踪到了哪条路线,但我试图绕过它所做的一切都无济于事 它在Chrome和Firefox中运行良好 是这条线引起了问题 this.prepedEvents[tmpDate.getFullYear()][tmpDate.getMonth()] 起初我认为可能是在我显式地将一个值设置为0索引时,但我不相信这是解决方案 我收到的错误是,“TypeErrorUndefined不是对象” 在更新PrePedEvents对象之前,我尝试使用虚拟数据初始化它。似乎没有什么帮助

这只发生在Safari中,我已经追踪到了哪条路线,但我试图绕过它所做的一切都无济于事

它在Chrome和Firefox中运行良好

是这条线引起了问题

this.prepedEvents[tmpDate.getFullYear()][tmpDate.getMonth()]

起初我认为可能是在我显式地将一个值设置为0索引时,但我不相信这是解决方案

我收到的错误是,“TypeErrorUndefined不是对象”

在更新PrePedEvents对象之前,我尝试使用虚拟数据初始化它。似乎没有什么帮助


  public constructor(private _jKiruService: JKiruService) { }

  public resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    return this._jKiruService
      .addRequest('Calendar', 'getDisplayable').runl();
  }
}
@Component({
  selector: 'app-learn-calendar',
  templateUrl: './learn-calendar.component.html',
  styleUrls: ['./learn-calendar.component.scss']
})
export class LearnCalendarComponent implements OnInit, OnDestroy {
  public preppedEvents = [];
  private _events = [];
  private _subscriptions: Subscription[] = [];

  constructor(
    private _route: ActivatedRoute,
    private _jKiruService: JKiruService,
    private _subscriber: SubscriptionService
  ) {
    this._subscriptions = this._subscriber.getSubscriber();
  }

  ngOnInit() {
    this._subscriptions['resolver'] = this._route.params.subscribe((res) => {
      if (res) {
        this._events = this._jKiruService.pull('calendar_event', true);
      }
    });
    this.prepEvents();
  }


  public prepEvents() {
    const currentDateObj = new Date();

    // Initial Loop
    for (let y = currentDateObj.getFullYear(); y < currentDateObj.getFullYear() + 2; y++) {
      this.preppedEvents[y] = [];

      for (let i = 0; i < 12; i++) {
        this.preppedEvents[y][i] = { month: OutwardDate.decodeMonth(i), events: [] };

      }
    }


    for (const event of this._events) {

      for (const day of event.events) {

        /**
         * important to note:
         * because of 0 index of month place, we need to add 1 to the display version
         * also need to format date from 2020-02-15 to 2020,02,15 to get accurate new date object
         */

        let tmpDate = new Date(day.day.replace(/-/g, ','));

            if (typeof this.preppedEvents[tmpDate.getFullYear()][tmpDate.getMonth()] === 'undefined' || this.preppedEvents[tmpDate.getFullYear()][tmpDate.getMonth()] === 'undefined' ) {
              return;
            }

        let monthDay = (tmpDate.getDate() < 10 ? '0' : '') + tmpDate.getDate();

        this.preppedEvents[tmpDate.getFullYear()][tmpDate.getMonth()].events.push({
          title: event.title,
          description: event.description,
          day: '' + (tmpDate.getMonth() + 1) + '/' + (monthDay) + '/' + tmpDate.getFullYear(), // we only need to add the 1 here to the month because its for display purposes, otherwise its index is correct
          start_time: day.start,
          end_time: day.end,
          time_description: day.description.replace(/<br>/g, ' ')
        });
      }
    }


    for (let y = currentDateObj.getFullYear(); y < currentDateObj.getFullYear() + 2; y++) {
      for (let i = 0; i < 12; i++) {

        this.preppedEvents[y][i].events = qsort2(this.preppedEvents[y][i].events, ['day', 'start_time']);
      }
    }

  }
}

公共构造函数(私有的jKiruService:jKiruService){}
公共解析(路由:ActivatedRouteSnapshot,状态:RouterStateSnashot){
把这个还给我
.addRequest('Calendar','getDisplayable').runl();
}
}
@组成部分({
选择器:“应用程序学习日历”,
templateUrl:“./learn calendar.component.html”,
样式URL:['./learn calendar.component.scss']
})
导出类LearnCalendarComponent实现OnInit、OnDestroy{
公共预行人事件=[];
私有_事件=[];
私人订阅:订阅[]=[];
建造师(
专用路由:激活的路由,
私人jKiruService:jKiruService,
私人订户:订阅服务
) {
this.\u subscriptions=this.\u subscriber.getSubscriber();
}
恩戈尼尼特(){
this._subscriptions['resolver']=this._route.params.subscripte((res)=>{
如果(res){
this.\u events=this.\u jKiruService.pull('calendar\u event',true);
}
});
这个.prepEvents();
}
公共活动(){
const currentDateObj=新日期();
//初始回路
for(设y=currentDateObj.getFullYear();y/g')
});
}
}
for(设y=currentDateObj.getFullYear();y
这是错误的屏幕截图以及出现的位置

****更新了一个链接****

这里有一个stackblitz链接,请确保您在Safari中,这样错误就会重现

这是您收到的唯一错误消息吗?@ams是的,而且只有在Safari中。在其他浏览器中一切正常。是否缺少一些多边形填充?@ams我不确定TBH。。。这是我的polyfills.ts文件@ams的截图,默认情况下也会添加这些文件