[英]Html not rendering javascript breaklines as intended
I have a json file which contains some texts, and some of these texts could have some breaklines 我有一个json文件,其中包含一些文本,其中一些文本可能会有一些断线
"surchargeNoteText":"Please note \r \n that pre-payments will take up to 2 business \r \n days to be allocated to your reservation",
I tried to use \\r and/or \\n and the result was this 我尝试使用\\ r和/或\\ n,结果是这样的
So, the funny thing is that when inspecting the html, the output is right, with 2 break lines. 因此,有趣的是,在检查html时,输出正确,带有2条换行符。
So, any tips here ? 那么,这里有什么提示吗?
Add below CSS will resolve your issue. 在CSS下方添加即可解决您的问题。 Thanks
谢谢
p.jss98 {
white-space: pre-wrap;
}
Use the <pre>
tag to keep the text formatted as you wish 使用
<pre>
标记使文本保持所需的格式
<pre> I am inside a pre Tag! <pre>
在HTML中,您需要添加<br />
来换行。
"surchargeNoteText":"Please note <br /> that pre-payments will take up to 2 business <br /> days to be allocated to your reservation",
Use
使用
instead of \\r
and <br/>
instead of \\n
. 代替
\\r
和<br/>
代替\\n
。 In HTML, \\r
and \\n
doesn't works. 在HTML中,
\\r
和\\n
不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.