admin管理员组文章数量:1316974
I want to render a dynamic html text provide by a API in react js but I don't know how to do.
for example :
dynamicHtml= <div> hello <span color=red> StackOverFlow </span> </div>
render() {
return (
<div> {dynamicHtml} </div>
);
}
I want to dysplay only Hello StackOverFlow with the red color on StackOverFlow
I want to render a dynamic html text provide by a API in react js but I don't know how to do.
for example :
dynamicHtml= <div> hello <span color=red> StackOverFlow </span> </div>
render() {
return (
<div> {dynamicHtml} </div>
);
}
I want to dysplay only Hello StackOverFlow with the red color on StackOverFlow
Share Improve this question asked Dec 17, 2017 at 19:27 Arnold MappsArnold Mapps 2101 gold badge4 silver badges11 bronze badges 3- I don't really understand what you're asking, what the question is, etc – Matt Fletcher Commented Dec 17, 2017 at 19:42
- I want to dysplay a dynamic html provided by a API. – Arnold Mapps Commented Dec 17, 2017 at 20:54
- 1 ... repeating what you say in your question is not the same as expanding on it. – Matt Fletcher Commented Dec 17, 2017 at 21:01
1 Answer
Reset to default 6use dangerouslySetInnerHTML
function createMarkup(text) { return {__html: text}; };
<render() {
return (
<div dangerouslySetInnerHTML={createMarkup()} />
);
}
本文标签: javascriptRender dynamic html in react jsStack Overflow
版权声明:本文标题:javascript - Render dynamic html in react js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742009798a2412675.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论