How does the string passed from the back end to the front end achieve line break in the pre tag

<pre>Labels can define pre-formatted text. Surrounded by the <pre>label
text in the element is usually reserved spaces and line breaks. The text will also be rendered in a monospaced font. Often used to represent computer source code.

Let's look at an example first:
Insert picture description hereas shown in the figure, in the prelabel, all spaces and line breaks are displayed according to the original format. In the divlabel, it is what we are familiar with. Spaces and line breaks are invalid. To change lines, you must use <br/>labels.
If we use the back-end string method, store it in the database, and then find out and display it to the front-end, or directly pass the string from the back-end to the front-end for display, if we want to wrap, directly at the place where the string needs to be wrapped Just add \n(note that it is not /n) .
Insert picture description here
Note: The characters are included \nin the database and stored in the database, and you can't see \nthe words in the query , but copy the corresponding character string and paste it into the notepad to open it, there will be a line break effect. For the convenience of the diagram, I modified the corresponding string literal directly in the database and added it manually \n. The effect is \nthat it will be displayed on the front end . In the above figure, I was also worried about \the escaping of symbols , and I added two \symbols to the database .

Guess you like

Origin blog.csdn.net/qq_41885819/article/details/107104028