最近 Angular DatePipe 显示 InvalidPipeArgument 错误,但字符串日期接缝是正确的。任何人都可以看到一些错误吗?这是我使用Typescript和Angular 6的代码
let datePipe: DatePipe = new DatePipe("es-ES");
let dia_sele: string = "";
try {
let fecha_formateada = this.datePipe.transform('23-01-2019', 'dd-MM-yyyy','es-ES');
dia_sele = fecha_formateada;
} catch (e) {
dia_sele = "";
console.log( "->err:" + e);
}
这是 Chrome Windows 控制台中显示的错误:
core.js:14597 ERROR Error: Uncaught (in promise): Error: InvalidPipeArgument: 'Unable to convert "23-01-2019" into a date' for pipe 'DatePipe'
Error: InvalidPipeArgument: 'Unable to convert "23-01-2019" into a date' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.transform