我有一個包含 html break 標記的字串來拆分字串,因為我想將字串拆分為多行,但它似乎沒有在 UI 中將字串呈現為多行。我怎樣才能實作以下目標?
testString = "This is line one<br>This is line two<br>This is line three"
預期輸出:
This is line one
This is line two
This is line three
我讀過dangerouslysettinginnerHTML但不想在我的代碼中使用它。就分裂而言,我所做的是我嘗試過
text.split('<br>').map(each => each <br>)
但這沒有用。任何提示或幫助將不勝感激。
uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/478303.html
標籤:javascript 反应
