转载自: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里写别的内容,否则会报错。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案