簡體   English   中英

如何在作為屬性傳遞的 JS object 中添加換行符?

[英]How to add line break into JS object that is passed as a property?

我使用了一個 JS 幫助文件,該文件由傳遞給呈現它的 function 的對象組成。 但是, \n 不起作用,我不確定如何添加換行符。 這是我的助手列表。

export const TweetList = [
{
    link: 'https://twitter.com/JayWuzer/status/1553804606265651200',
    tweet: "Being your full authentic self is a life hack. \n The ones who don't vibe with you will naturally be repulsed, and the ones who do vibe with you will naturally be drawn to you. \n Saves a LOT of time and heartache.",
    date: 7/31/2022
}, 

這是我的 function 渲染文本。 無法正確格式化,所以我使用了圖像。

您需要添加 styles

whiteSpace: 'pre-line'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM