2017-03-01 35 views
0

我正在使用FormattedDate來顯示時間,我想知道是否可以對每個單獨部分的時間進行樣式設置。 我成功地設計了小時和分鐘的風格,但「PM」的「AM」如何呢?我可以設計<FormattedDate />的單個元素嗎?

我的目標是有類似的東西附加圖像

enter image description here

+0

不要以爲得到期望的結果所以。無論如何,這種格式並不是真正的語言環境。 – Aaron

回答

0

我做了一些研究,並就GitHub的回購張貼的問題作爲一個問題作出反應,國際 下面是答案我得到:

"This is not currently possible, but this is the exact use-case for the 
formatToParts() API that we standardized as part of JavaScript! 
Eventually we'll use this API directly within React Intl." 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts

替代解決方案:

在我的研究,我發現了另一個有趣的NPM模塊調用DateFormat 的工具是非常靈活的,我是能夠通過造型日期的每一個元素

相關問題