Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript-如何添加';br';成段_Javascript_Backbone.js - Fatal编程技术网

Javascript-如何添加';br';成段

Javascript-如何添加';br';成段,javascript,backbone.js,Javascript,Backbone.js,我正在使用backbone.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 S6

我正在使用backbone.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.

您可以在javascript中使用正则表达式在每个句子后添加换行符

后跟大写字母的期间的搜索参数为
/\(?=[a-Z])/g

description.replace(/\.(?=[A-Z])/g,
);
拆分
加入

@elclanrs-这会有点风险,因为他可能会在他们不应该在的地方拥有

。例如:
0.7
将变为
0
7
是的,只是在那里给出一个提示,希望OP会尝试一些东西并发布代码什么界定了你的段落?新行?如果他按
分开,那么段落中使用的
仅为0.7
呢?
The COOLPIX S620 combines beauty and brains. It features the worlds fastest start up in just 0.7 seconds.
description.replace(/\.(?=[A-Z])/g, '<br />');