Aak*_*ani 4 timestamp typescript angularfire angular
timestamp我正在尝试使用将Firestore 中的对象转换为DateTypeScript 中的对象toDate()。
import { AngularFirestore } from '@angular/fire/firestore';
...
constructor(private database?: AngularFirestore) {...}
...
const someVariable = a.date.toDate();
Run Code Online (Sandbox Code Playgroud)
虽然该功能在开发模式下工作正常,但我收到 TypeScript 编译检查错误。ng prod此外,由于此错误,我无法构建产品版本(使用)。
a.date.toDate() ~~~~ src/app/project/some.service.ts:74:36 -
错误 TS2339:类型“Date”上不存在属性“toDate”。
有什么建议我该如何解决这个问题吗?
toDate() 不适用于日期、字符串、数字等。将日期类型更改为任何时间戳。
date: any;
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我通常会在 html 文件中使用 toDate() 。它会显示错误但可以编译。输入any也将清除html 错误。
| 归档时间: |
|
| 查看次数: |
8443 次 |
| 最近记录: |