打字稿日期类型?(Typescript Date Type?)
如何在TypeScript中表示日期? 日期不是TypeScript类型 ,所以我使用any或object ? 似乎有一个“正确”的方法可以做到:
let myDate: any = new Date();尽管这是一个简单的问题,但我无法在Google上找到太多内容。
How do I express dates in TypeScript? Dates aren't a TypeScript type, so do I use any or object? Seems like there would be a "right" way to do:
let myDate: any = new Date();I couldn't find much on Google, despite it being such a simple question.
最满意答案
答案非常简单,类型是Date :
const d: Date = new Date(); // but the type can also be inferred from "new Date()" already它与其他所有对象实例相同:)
The answer is super simple, the type is Date:
const d: Date = new Date(); // but the type can also be inferred from "new Date()" alreadyIt is the same as with every other object instance :)
更多推荐
发布评论