Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript gotoDate fullcalendar无法在typescript中工作_Javascript_Typescript_Fullcalendar_Aurelia_Fullcalendar 4 - Fatal编程技术网

Javascript gotoDate fullcalendar无法在typescript中工作

Javascript gotoDate fullcalendar无法在typescript中工作,javascript,typescript,fullcalendar,aurelia,fullcalendar-4,Javascript,Typescript,Fullcalendar,Aurelia,Fullcalendar 4,在我的typescript页面上,我正在访问fullcalendar api,如下所示: import { Component } from "../../../common.aurelia/component"; import { Calendar ,EventInput} from '@fullcalendar/core'; import integrationPlugin from '@fullcalendar/interaction'; import { bindab

在我的typescript页面上,我正在访问fullcalendar api,如下所示:

import { Component } from "../../../common.aurelia/component";
import { Calendar ,EventInput} from '@fullcalendar/core';
import integrationPlugin from '@fullcalendar/interaction';
import { bindable, inject, Aurelia } from 'aurelia-framework';
export class CCalendar extends Component {
    @bindable() initialView: string;    
    @bindable() events: Array<any> = [];
    
    calendarElement: HTMLDivElement;
    private calendar: Calendar;
    constructor(private element: any, aurelia: Aurelia) {
                super(aurelia);
            };
    attached() {
        this.calendar = new Calendar(this.calendarElement, {
            plugins: [integrationPlugin],
            initialView: this.initialView,          
            events: this.events,
            eventClick: (info) => this.eventClicked(info),
        });
        this.calendar.render();
    }
    
    public addEvent(eventInput: EventInput) {
        this.calendar.addEvent(eventInput);
    }

    public gotoDate(date:any) {
        this.calendar.gotoDate(date); // not working
    }
除了我的gotoDate函数之外,上面的一切都可以工作。 我有一个日期选择器,希望将日期传递给goToDate函数,以便日历将焦点放在该日期上

它失败并表示无法读取“TypeError:无法读取CCalendar.gotoDate处未定义的属性'gotoDate'”


我做错了什么?

我注意到您的两个组件的名称相同。我猜公共日历字段仍然未分配,因此未定义。对不起,它不一样,让我更新一下,是一个输入错误。请显示准确的错误消息,以及哪行代码导致itvar date=2020-12-19。。。日期字符串需要在引号中。我以前也尝试过使用引号,但它不起作用。它说“TypeError:Cannotreadproperty'gotoDate'of undefined at CCalendar.gotoDate”,我注意到两个组件的名称相同。我猜公共日历字段仍然未分配,因此未定义。对不起,它不一样,让我更新一下,是一个输入错误。请显示准确的错误消息,以及哪行代码导致itvar date=2020-12-19。。。日期字符串需要在引号中。我以前也尝试过使用引号,但它不起作用。它表示“TypeError:无法读取CCalendar.gotoDate处未定义的属性'gotoDate'”
export class Calendar extends Component {
    
    public calendars: CCalendar ;

async test()
{ var date=2020-12-19 // also tried var date="2020-12-19"
  this.calendars.gotoDate(date);

}
}