使用
<nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="startDate"></nz-date-picker>
后端返回的是string类型
safari浏览器报错 Invalid Date
safari浏览器不支持yyyy-MM-dd 格式,但支持yyyy/MM/dd
new Date(data.startDate).getTime() 时得到NAN
解决:用正则替换 .replace(/-/g,“/”)
this.prepaymentFlowForms.controls.startDate.setValue(new Date(data.createdTime.replace(/-/g, '/')));