react解析html标签组成的字符串

转载自:https://blog.csdn.net/tongshuo_11/article/details/61195232

var content = '<strong>content</strong>';// 假设content是从接口获取到的数据

react.render(
    <div dangerouslySetInnerHTML = {{ __html:content }}></div>,
    document.body
)

这里要注意,这样这个div只能放这个html解析的内容,不能再在div里写别的内容,否则会报错。

posted @ 2018-07-26 15:09  蓓蕾心晴  阅读(2198)  评论(0编辑  收藏  举报