[Front-end vue] elementui textarea displays line break problem

When using the text field, when it comes to line breaks, there is no line break effect when displayed on the page. In fact, the line break saved in the text field is /r/n. The browser cannot recognize this kind of line break, so it needs to be replaced when echoing Browser-readable code

 The solution is to replace all spaces and line breaks in the text

 

data.content = '<p>' + data.content.replace(/ /g, '&nbsp;').replace(/\n|\r\n/g, '</p><p>') + '<p>'

Guess you like

Origin blog.csdn.net/qq_39078783/article/details/127565720