我有一個組件,它使用injectIntl
-HOC,並返回一個消息反應,國際反應呈現組件作爲佔位符FORMATMESSAGE
...
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> }}>
反而呈現正確。
有沒有人有線索?