簡體   English   中英

Javascript-如何在段落中添加“ br”

[英]Javascript - How to add 'br' into paragraph

我正在為我的移動應用程序項目使用bone.js。 我的問題是如何在段落中添加“ br”? 這是我的代碼。

<p><%= product.get('description') %></p>

數據庫中的數據

The COOLPIX S620 combines beauty and brains. 
It features the worlds fastest start up in just 0.7 seconds.

我想要的就是這樣

The COOLPIX S620 combines beauty and brains. 

It features the worlds fastest start up in just 0.7 seconds.

不是這個

The COOLPIX S620 combines beauty and brains. It features the worlds fastest start up in just 0.7 seconds.

您可以在javascript中使用正則表達式在每個句子后添加換行符。

句號后跟大寫字母的搜索參數為/\\.(?=[AZ])/g

description.replace(/\.(?=[A-Z])/g, '<br />');

暫無
暫無

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

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