【发布时间】:2017-04-20 02:10:17
【问题描述】:
我正在从 gmail 获取一封电子邮件,并获取了带有 CSS 标记的 html。我想在 React 应用程序中呈现它,但 React 将它解释为字符串与 html。
如何告诉 react 渲染 HTML/CSS?
var AnotherComponent = React.crateClass({
render: function() {
return (
<div>{this.props.html_email}</div>
)
}
})
var Test = React.createClass({
render: function() {
return (
<AnotherComponent html_email = {this.props.html_body} />
)
}
})
在这种情况下,html_body 是
<div><p style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt;" data-mce-style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt;"><span style="font-family: Arial; color: #222222; vertical-align: baseline; white-space: pre-wrap;" data-mce-style="font-family: Arial; color: #222222; vertical-align: baseline; white-space: pre-wrap;">SOME TEXT</span></p><br><p style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt;" data-mce-style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt;"><span style="font-family: Arial; color: #222222; vertical-align: baseline; white-space: pre-wrap;" data-mce-style="font-family: Arial; color: #222222; vertical-align: baseline; white-space: pre-wrap;">
它将所有 html 显示为字符串而不是 SOME TEXT
【问题讨论】:
标签: javascript reactjs