我正在尝试使用角度材料网站上的基本日期选择器。
<span class="calendar">
<mat-form-field appearance="outline">
<mat-label>Date</mat-label>
<input
matInput
[matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</span>
但是当我单击 datepicker 时出现以下错误
core.js:6185 ERROR TypeError: format.replace is not a function
at expandFormat (moment.js:537)
at formatMoment (moment.js:521)
at Moment.format (moment.js:3975)
at MomentDateAdapter.format (material-moment-adapter.js:126)
at MatCalendarHeader.get periodButtonText [as periodButtonText] (datepicker.js:2094)
at MatCalendarHeader_Template (datepicker.js:2233)
at executeTemplate (core.js:11949)
at refreshView (core.js:11796)
at refreshComponent (core.js:13229)
at refreshChildComponents (core.js:11527)
但是当在堆栈闪电战中尝试相同的代码时,它可以工作。此外,我正在从“@angular/material/datepicker”导入和导出 { MatDatepickerModule };在模块中。这没用。
各位能不能给点建议