我正在从mongodb调用一个字符串并将其放置在这样的卡体内:
{this.state.news.map(item => (
<Card
title={item.headline}
>
{item.description}
</Card>
))};
我在页面上看到的所有内容看起来像一块实心文本。我尝试了各种/n
<br/>
和<br />
都无济于事。
在提出一些建议之后,我尝试将/n
重新添加到字符串和<pre>
标签中。.
{this.state.news.map(item => (
<Card
title={item.headline}
>
<div classname="storyText">
<pre>
{item.description}
</pre>
</div>
</Card>
))};
和匹配的CSS
.storyText{
white-space: pre ;
}
但是其中任何一个都完全破坏了我的网格并破坏了页面(当然有不同的方式)。