我有一个组件,它使用injectIntl
-HOC,并返回一条消息
...
return (
<Message>
{intl.formatMessage({
id: 'page.checkout.hint'
}, {
link: <b>{intl.formatMessage({ id: 'page.checkout.hint.hyperlink' })}</b>
})}
</Message>
)
...
我的语言文件如下所示:
...
"page.checkout.hint": "You're going to be redirected automatically. If nothing happens, please click {link}",
"page.checkout.hint.hyperlink": "here",
...
这导致:You're going to be redirected automatically. If nothing happens, please click [object Object]
。
如果我改用<FormattedMessage id="page.checkout.hint" values={{ link: <b>{intl.formatMessage({ id: 'page.checkout.hint.hyperlink' })}</b> }}>
正确渲染。
有人有线索吗?