我已决定本周开始学习React ,因为这个特定的框架有很多工作。
我来自一个Angular背景,发现自己想知道React中是否有一个选项与Angular的DatePipe的目的相匹配。
I've decided to start learning React this week, since there are so many jobs out there for this particular framework.
I come from an Angular background, and found myself wondering if there is an option in React that matches the purpose of Angular's DatePipe.
最满意答案
React API没有内置的功能来处理这个问题,Angular管道涵盖的所有功能通常都是这样。 相反,您在React中有三种日期格式选项:
本地日期处理,例如Intl.DateTimeFormat
专业React组件,例如react-moment
可以操纵日期的外部程序包,如moment
要使用哪个取决于你的具体需求,但总的来说,我会建议他们按照他们的顺序。
There is not a built-in feature of the React API that handles this for you, which is generally the case for all of the functionality covered by Angular pipes. Instead, you have really three options for date formatting in React:
Native date handling, for example Intl.DateTimeFormat
Specialized React component, for example react-moment
External package that can manipulate dates, such as moment
Which to use depends on your specific needs, but in general I would recommend those in the order they are given.
更多推荐
发布评论