1

I'm trying to display a formated text in Vue.

In a component, I have a textarea saving a string with backspaces, etc ... in an API like this :

Une cave mais pas que ...\n\nBienvenue à la cave Nature & Vins, véritable caverne d’Ali-baba pour assoiffés de découvertes œnologiques, spiritueuses, brassicoles et gastronomiques. Notre crédo : la convivialité et la simplicité, notre point d’honneur : vous procurer du bonheur que vous soyez néophytes ou connaisseurs. Nous sélectionnons en toute indépendance nos vins, nos bières et nos spiritueux en recherchant l’authenticité, l’originalité ainsi qu’une éthique garante du respect de l’environnement et de la santé.\n\nDes séances de dégustation des vins, bières et spiritueux vous sont proposées afin que vous puissiez acquérir les clés de compréhension de ces magnifiques produits dans une ambiance conviviale 100% garantie dénuée de pédantisme et de snobisme.\n\n

And in my template, I'm retrieving data and displaying it. The problem is I don't have backspaces and it's displaying like that : enter image description here

To retrieve my text, I'm using this :

<p>{{ findContent('60f5951649b96602c029af99') }}</p>

where my method findContent returns the content as a String from an array

Do someone have any idea on how to display it properly ?

2 Answers 2

4

Try to use white-space:pre-wrap rule :

 <p style="white-space:pre-wrap">{{ findContent('60f5951649b96602c029af99') }}</p>
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I didn't saw your comment ... But with that's it's working ! Sorry
1

I solved it by adding the style : white-space: pre-wrap like this :

<p style="white-space: pre-wrap">{{ findContent('60f5951649b96602c029af99') }}</p>

1 Comment

it should be style= not style:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.