在运行angular时提示错误,如下错误代码:
InnerPopupComponent.html:1 ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "zh-cn".' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.push../node_modules/@angular/common/fesm5/common.js.DatePipe.transform (common.js:4940)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDate (ng-zorro-antd.js:4967)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDateCompatible (ng-zorro-antd.js:4990)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.formatDateTime (ng-zorro-antd.js:13810)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.createYearMonthDaySelectors (ng-zorro-antd.js:13830)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.render (ng-zorro-antd.js:13761)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.ngOnChanges (ng-zorro-antd.js:13650)
at checkAndUpdateDirectiveInline (core.js:20661)
at checkAndUpdateNodeInline (core.js:21929)
View_InnerPopupComponent_0 @ InnerPopupComponent.html:1
InnerPopupComponent.html:1 ERROR CONTEXT DebugContext_
View_InnerPopupComponent_0 @ InnerPopupComponent.html:1
InnerPopupComponent.html:12 ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "zh-cn".' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.push../node_modules/@angular/common/fesm5/common.js.DatePipe.transform (common.js:4940)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDate (ng-zorro-antd.js:4967)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.makeHeadWeekDays (ng-zorro-antd.js:14226)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.render (ng-zorro-antd.js:14189)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.ngOnChanges (ng-zorro-antd.js:14139)
at checkAndUpdateDirectiveInline (core.js:20661)
at checkAndUpdateNodeInline (core.js:21929)
at checkAndUpdateNode (core.js:21891)
at debugCheckAndUpdateNode (core.js:22525)
View_InnerPopupComponent_0 @ InnerPopupComponent.html:12
InnerPopupComponent.html:12 ERROR CONTEXT DebugContext_
View_InnerPopupComponent_0 @ InnerPopupComponent.html:12
InnerPopupComponent.html:1 ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "zh-cn".' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.push../node_modules/@angular/common/fesm5/common.js.DatePipe.transform (common.js:4940)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDate (ng-zorro-antd.js:4967)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDateCompatible (ng-zorro-antd.js:4990)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.formatDateTime (ng-zorro-antd.js:13810)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.createYearMonthDaySelectors (ng-zorro-antd.js:13830)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.render (ng-zorro-antd.js:13761)
at CalendarHeaderComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.CalendarHeaderComponent.ngOnChanges (ng-zorro-antd.js:13650)
at checkAndUpdateDirectiveInline (core.js:20661)
at checkAndUpdateNodeInline (core.js:21929)
View_InnerPopupComponent_0 @ InnerPopupComponent.html:1
InnerPopupComponent.html:1 ERROR CONTEXT DebugContext_
View_InnerPopupComponent_0 @ InnerPopupComponent.html:1
InnerPopupComponent.html:12 ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "zh-cn".' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.push../node_modules/@angular/common/fesm5/common.js.DatePipe.transform (common.js:4940)
at NzI18nService.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzI18nService.formatDate (ng-zorro-antd.js:4967)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.makeHeadWeekDays (ng-zorro-antd.js:14226)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.render (ng-zorro-antd.js:14189)
at DateTableComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.DateTableComponent.ngOnChanges (ng-zorro-antd.js:14139)
at checkAndUpdateDirectiveInline (core.js:20661)
at checkAndUpdateNodeInline (core.js:21929)
at checkAndUpdateNode (core.js:21891)
at debugCheckAndUpdateNode (core.js:22525)
View_InnerPopupComponent_0 @ InnerPopupComponent.html:12
InnerPopupComponent.html:12 ERROR CONTEXT DebugContext_
如下图所示:
提示此错误是需要在model中引入registerLocaleData(zh),如下代码:
import zh from '@angular/common/locales/zh';
import {registerLocaleData} from '@angular/common';
registerLocaleData(zh);
如下图所示: