我有一个像这样的琴弦
let str = "You would get items\nwhich value about **$50**\nif you **pre-booked** it!"
我想替换\n为,<br/>并使用以下代码实现了它。
str.split('\n').map((line)=>(<span>{line}<br/></span>)
我取得了什么
<span>You would get items<br/></span>
<span>which value about $50<br/></span>
<span>if you pre-booked it!</span>
现在,我想强调一些这样的词。
我期望什么
<span>You would get items<br/></span>
<span>which value about <b>$50</b><span>
<span>if you <b>pre-booked</b> it!</span>
我想像下面这样使用。
const TextFormat = ({text}) => (
<React.Fragment>
{
text.split('\n').map((line, i) => (<span key={i}>{line}<br/></span>)
}
</React.Fragment>
)
白猪掌柜的
扬帆大鱼
相关分类