简体   繁体   English

react-intl不会更改占位符的值

[英]react-intl not changing placeholder value

Am I doing something wrong here ? 我在这里做错什么了吗?

I am calling intl.formatMessage() API ( https://github.com/yahoo/react-intl/wiki/API#formatmessage ) as follows: 我正在调用intl.formatMessage() API( https://github.com/yahoo/react-intl/wiki/API#formatmessage ),如下所示:

this.intl.formatMessage({id:'downloadRequest.success',values:{correlID:'test'}})

The string in my JSON file looks like: 我的JSON文件中的字符串如下所示:

 "downloadRequest.success": "Your request was successfully submitted. Your reference ID is: {correlID}"

However, when I view the page, the output is : 但是,当我查看页面时,输出为:

Your request was successfully submitted. Your reference ID is: {correlID}

ie {correlID} is not substituted for the test value provided to formatMessage() {correlID}不能替代提供给formatMessage()test

您应该将值作为第二个参数传递。

this.intl.formatMessage({id:'downloadRequest.success'},{correlID:'test'})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM