0

我使用的是Angular 8 DayPilot Scheduler,它能够在从链接重定向时很好地显示调度程序图表,但是如果直接输入URL或刷新当前调度程序页面,调度程序图表将消失并出现错误:

SchedulerComponent.html:1 ERROR Error: DayPilot.Scheduler: The placeholder element not found: 'dp_157775431314089808'.
    at viewWrappedDebugError (core.js:19411)
    at callWithDebugContext (core.js:30049)
    at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:29741)
    at ViewRef_.push../node_modules/@angular/core/fesm5/core.js.ViewRef_.detectChanges (core.js:20458)
    at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.tick (core.js:26837)
    at core.js:26726
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.js:25986)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)

我的 SchedulerComponent.html 第 1 行:

<daypilot-scheduler [config]="config" [events]="events" #scheduler></daypilot-scheduler>
4

1 回答 1

0

我能够通过应用以下替代解决方案来修复它:刷新页面时强制重新渲染组件虽然控制台错误仍然存​​在,但至少现在可以使用调度程序

html

<div *ngIf="_reload">
<daypilot-scheduler [config]="config" [events]="events" #scheduler></daypilot-scheduler>
</div>

ts

export class SchedulerComponent implements AfterViewInit{
_reload = true;

  constructor() {}

  private reload() {
    setTimeout(() => (this._reload = false));
    setTimeout(() => (this._reload = true));
  }

  public ngAfterViewInit(): void {
    this.reload();
  }
}
于 2020-02-03T08:21:47.067 回答