Rendering newline character in VueJS

前端 未结 6 1228
离开以前
离开以前 2020-12-24 00:06

I\'m creating a note app where users can add a note by entering multiline text in a textarea. When I save the note in Firebase it is being saved with newline (\\n) character

6条回答
  •  时光取名叫无心
    2020-12-24 01:07

    As @shelvacu said the

     html tag preserves whitespaces. 

    However using it has one serious disadvantage: the tag itself inherits plenty of unnecessary styling from CSS frameworks that are used in project (e.g. Bootstrap).

    To preserve whitespaces and avoid inheriting any unnecessary styles use:

    Some whitespaced content
    

    what will act exacly like the

     tag.

    Be aware that white-space: pre remains text 'as it is' - if you would like to have additional line break when it's necessary use: white-space: pre-wrap.

    See: w3schools.com CSS white-space Property

提交回复
热议问题