我在这里做错什么了吗?
我正在按以下方式调用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
的{{1}}值
答案 0 :(得分:1)
您应该将值作为第二个参数传递。
this.intl.formatMessage({id:'downloadRequest.success'},{correlID:'test'})