我正在使用 angular 10 和 fullcalender 5.3.1。出于某种原因,我无法将 fullcalender initialView 设置为日视图。它总是卡在 dayGridMonth 视图中
这是 html -
<full-calendar id="calendar"
#calendar
[options]="calendarOptions"
[plugins]="options.plugins"
[editable]="true"
[height]="'parent'"
[dir]="'ltr'"
[events]="courseModel"
(dateClick)="onDateClick($event)"
(eventClick)="onEventClick($event)"
>
</full-calendar>
这是我的 ts 代码
constructor( private courseservice: CourseService ,
public dialog: MatDialog) { }
@ViewChild('calendar') calendarComponent: FullCalendarComponent;
calendarEvents: EventInput[] = [];
initialized = false;
ngOnInit(): void {
this.courseservice.getAll().subscribe(data =>{
this.courseservice.getAllDetails().subscribe(detdata =>{
console.log("detaildata-", detdata)
detdata.map((detval,detind)=>{
this.courseModel.push({
title: data.find(x=>x.id == detval.courseId).schoolName,//detval.courseName,
date: moment(detval.startDate).format('YYYY-MM-DD'),
start: moment(detval.startDate).format('YYYY-MM-DD'),
end: moment(detval.endDate).format('YYYY-MM-DD'),
color: this.colorarr[(detind+1)%5],
courseName:detval.courseName,
})
if(detdata.length-1 == detind){
this.calendarOptions = {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGrid,dayGridMonth,listWeek'
},
initialView: 'dayGrid',
dayMaxEvents: true, // allow "more" link when too many events
events: this.courseModel,
eventClick: function(info) {
console.log("info--", info.event)
this.info = info.event.title
}.bind(this)
};
this.initialized = true
}
})
})
})
this.options = {
editable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
plugins: [listPlugin,dayGridPlugin, interactionPlugin, timeGridPlugin]
};
}
onEventRender(info: any) {
console.log('onEventRender', info.el);
const tooltip = new Tooltip(info.el, {
title: info.event.title,
placement: 'top-end',
trigger: 'hover',
container: 'body'
});
}
我还尝试设置为 dayGridWeek 或 listweek 等其他视图。没有任何工作。我还尝试在 html 中设置初始视图——
<full-calendar id="calendar"
#calendar
[options]="calendarOptions"
[plugins]="options.plugins"
[editable]="true"
[height]="'parent'"
[initialView] = "'listWeek'"
[dir]="'ltr'"
[events]="courseModel"
(dateClick)="onDateClick($event)"
(eventClick)="onEventClick($event)"
>
</full-calendar>
也不起作用
这是视图
任何帮助都会得到帮助