我从CMS获得HTML字符串形式的“正文”内容
正文:"<h1>This is the title</h1><p>This is the body</p>"
我不想使用dangerouslySetInnerHTML={{ __html: body }}
我宁愿将内容作为对象,即:
const content = {
h1: This is the title,
p: this is the body,
h1: this is another title,
p: this is another body
}
然后,我可以将其Object.entries(content).map...
放入Text
组件中。
我要朝正确的方向前进吗?有什么选择?