[英]FormattedNumber component from react-intl doesn't work
I am trying to use the component FormattedNumber
from the react-intl
library but I can't make it to work. 我试图使用
react-intl
库中的组件FormattedNumber
,但我无法使其工作。
<IntlProvider
locale="en-US"
messages={locales['en-US']}
>
<div>
<FormattedNumber value={123456} />
<FormattedNumber value="123456" />
</div>
</IntlProvider>
This only returns the value the way I passed it to the component, wrapped with a span, but it doesn't format the number. 这只返回我传递给组件的方式,用span包装,但它不格式化数字。
I get an error in the console: 我在控制台中收到错误:
[React Intl] Error formatting number.
[React Intl]错误格式化编号。 TypeError: Bind must be called on a function
TypeError:必须在函数上调用Bind
The FormattedMessage
component works fine for all my translations, the locale is set to en-US
, so I don't think the issue comes from the IntlProvider
or something else. FormattedMessage
组件适用于我的所有翻译,语言环境设置为en-US
,所以我不认为问题来自IntlProvider
或其他东西。
I am using the latest version of the library, 2.0.1
我正在使用最新版本的库
2.0.1
Any idea? 任何想法?
I have the same issue. 我有同样的问题。 In my case problem was in global definition window.Intl.
在我的情况下问题是在全局定义窗口.Intl。 It rewrite the original lib object and lose functions context
它重写原始的lib对象并丢失函数上下文
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.