VueJS newline character is not rendered correctly

前端 未结 3 1479
心在旅途
心在旅途 2021-02-19 00:39

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

3条回答
  •  被撕碎了的回忆
    2021-02-19 00:49

    I was facing same issus i was using vue-nl2br

    check it here

    Install

    npm install --save vue-nl2br
    

    Usage

    import Nl2br from 'vue-nl2br'
    
    Vue.component('nl2br', Nl2br)
    

    View

    
    

    result :

    myLine1
    myLine2

提交回复
热议问题