I got the following problem, I read data string from an API which contains new line characters \n
and I want to display them correctly in my template.
But when I do something like:
<p>{{ mytext }}</p>
The text is display with \n
characters in it like normal text.
The text string from the response is in the format of "Hello, \n what's up? \n My name is Joe"
.
What am I doing wrong here?
I was facing same issus i was using
vue-nl2br
check it here
Install
Usage
View
result :
Not even a vue issue you could simply use CSS and apply
white-space: pre;
to the content. You shouldn't need an additional package for this.Use the
<pre></pre>
tag to preserve the preformated text. More info MDN Pre tag docs