我在这里做错什么了吗?
我正在按以下方式调用intl.formatMessage()
API(https://github.com/yahoo/react-intl/wiki/API#formatmessage):
this.intl.formatMessage({id:'downloadRequest.success',values:{correlID:'test'}})
我的JSON文件中的字符串如下所示:
"downloadRequest.success": "Your request was successfully submitted. Your reference ID is: {correlID}"
但是,当我查看页面时,输出为:
Your request was successfully submitted. Your reference ID is: {correlID}
即
{correlID}
不能代替提供给test
的formatMessage()
值 最佳答案
您应该将值作为第二个参数传递。
this.intl.formatMessage({id:'downloadRequest.success'},{correlID:'test'})