js操作文章、字符串换行

操作前:

操作后:

 

第一步:

把中英文的逗号和顿号置换为 '\n’

support_unit = support_unit.replace(/,|,|、/g, '\n')
 
第二步:
 //为了使\n生效
    white-space: pre;

参考:https://blog.csdn.net/ccmedu/article/details/82021065

猜你喜欢

转载自www.cnblogs.com/ww01/p/10764081.html