如何在数组中实现 span 标签到 html

how to implement span tag in an array to html

let array= ["<span style="font-weight:900">everthing</span> is perfect", "Look for opportunities in <span style="font-weight:900">every</span>change"]

array.map((arr) => {
          return (
              <div>
                {arr}
              </div>
          );
        })

期望的输出:

一切都是完美的 在每个变化

中寻找机会

我的输出:

<span style="font-weight:900">everthing</span> is perfect 
Look for opportunities in <span style="font-weight:900">every</span>change

请帮助我。

您必须为此安装一个包。

yarn add react-html-parser
npm install react-html-parser

然后。

import ReactHtmlParser from 'react-html-parser'; 
<div> { array.map((arr)=>(
    {ReactHtmlParser (arr)}
)) } </div>