在我的 NFTDetails 組件中是來自 JSON 的描述。里面有\n\n。當我在 div 中使用 JSON 的值時沒有新行,但是當我 console.log() 時,Firefox 控制臺中有新行。
如何使用 \n 在我的 div 中顯示新行。
NFTDetails.jsx - 片段
const NFTDetails = ({nfts}) => {
const { id } = useParams();
const navigate = useNavigate()
const metadata = useMemo(
() => nfts.find((nft) => String(nft.id) === id),
[nfts, id]
);
return (
<div className="NFTDetails">
<div className="TextCard">
<div className="NFTCName">{metadata.name}</div>
<div className="Description">
<p className='DescriptionText'>Description:</p>
<p>{metadata.description}</p>
</div>
</div>
元資料描述(JSON)
{
"description":"e?§? CLONE X e?§?\n\n20,000 next-gen Avatars, by RTFKT and Takashi Murakami e???\n\nIf you own a clone with even one Murakami trait please read the terms regarding third-party content here: https://rtfkt.com/legal-2B.\n\nYou are not entitled to a commercial license if you own an avatar with any traits created by Murakami."
}
uj5u.com熱心網友回復:
用于white-space: pre-line;在描述中留下空格
https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/487595.html
標籤:javascript 反应 json 格式化
上一篇:避免偶爾長時間運行的資料庫更新和對該資料庫的查詢重疊
下一篇:Junit和集成測驗的最佳方法
