答案 0 :(得分:0)
在HTML文件中的<br>
标记后添加<mat-calendar>
。
<div *ngFor="let m of months">
<mat-calendar [dateClass]="dateClass()" [startAt]="m" [selected]="selectedDate"
(selectedChange)="onSelect($event)"></mat-calendar>
<br>
</div>
答案 1 :(得分:0)
您可以为此使用普通的DOM函数:
@ViewChildren(MatCalendar, {read: ElementRef}) calendars: QueryList<ElementRef>;
ngAfterViewInit() {
this.calendars.forEach(calendarEl => {
const tbody: HTMLElement = calendarEl.nativeElement.querySelector('tbody');
const tr = document.createElement('tr');
for (let i = 0; i < 7; i++) {
tr.appendChild(document.createElement('td'));
}
tbody.appendChild(tr);
})
}
如果日历表的最后一行没有7列,则需要添加内容并进行调整。