Rendering newline character in VueJS

前端 未结 6 1229
离开以前
离开以前 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:04

    Wrap the content in a pre element.

    A

     element will preserve whitespace within it, eg:

    This is followed by a newline,
    not that you can tell
    

    You can see the newline after me!
    Woohoo!

    Will result in:

    This is followed by a newline, not that you can tell
    
    You can see the newline after me!
    Woohoo!
    

    This way, you do not need to do any filtering of newlines.

提交回复
热议问题