SoFunction
Updated on 2025-03-03

WeChat applet text display line breaking problem

Small program text display line break

question

When the user uploads pictures and texts, enter a newline character. This caused me to report an error after getting the data.

Probably this structure:

[{
  text:'The front end of the down and out

 Fry the noodles online!  !  !  ' ,
  url:''
},{
  text:'' ,
  url:'',
}]

solve

When you get the data, perform regular matching processing first, and replace the line break with \n

(/\n/g,'\\n')

Then there is no problem in progress.

It should also be noted that you must use the text tag to output before the line break will be displayed.

ps: Let's take a look at the text of the WeChat applet that exceeds the automatic line wrapping

text-overflow:ellipsis;
word-wrap:break-word;

Summarize

The above is the WeChat mini program text display line breaking problem introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!