Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是想创建一个从现在起 3 天的日期,以便在打字稿角度组件中使用。
我看过Angular2 时刻,但这似乎只与管道有关。虽然我确实看过这篇关于在代码中使用管道的文章,但看起来有点 hacky...
也许我错过了一些东西,因为这应该很简单?!
谢谢
date: Date; ngOnInit() { this.date = new Date(); this.date.setDate( this.date.getDate() + 3 ); }
然后您可以使用日期管道在 HTML 中很好地显示日期
{{ date | date }}
因此呈现:
2017 年 9 月 25 日