我在一个对象中有一个字符串,其中包含一些 HTML 标签,我想使用 map 函数打印该对象内的值。
const tableBody = [
{
date: '02/08/2019',
item: 'Renewed your <strong>current Team Plan</strong>'
},
{
date: '05/09/2019',
item: 'Renewed your current Team Plan 2'
},
{
date: '15/10/2019',
item: 'Renewed and upgraded to the <strong> Business Plan </strong> with 3 new members'
}
];
<table>
{tableBody.map(tableBody => (
<tr>
<td>{tableBody.date}</td>
<td>{tableBody.item}</td>
</tr>
))}
</table>
当我运行此代码时,我希望<strong>
将字符串中的标记编译为 HTML 元素,而不是呈现为纯文本。那么有没有办法实现这些家伙?