sofiane
sofiane

Reputation: 23

how can i formating text with vue.js

Hi i wanna try to formate text to break line after ***
this is only part of the script i think the problem is on computed part maybe i wrote something wrong i have already tried this:

<div v-html="post.case_history"></div>

and this:

computed() {
    post.case_history.replace('***', '<br>')
  }

I got this error

Invalid value for option "computed": expected an Object, but got Function.

Upvotes: 0

Views: 118

Answers (2)

sofiane
sofiane

Reputation: 23

Thanks lot i have found the solution:

<div v-html="history(post)"></div>


methods: {
    history(post) {
        return post.case_history.replace('***', '<br>') . replace(/\*\*\*/g, '<br>').replace(/------------------------------/g, '<br>');
    }
}

Upvotes: 0

niclas_4
niclas_4

Reputation: 3674

 computed: {
       postCased: function() {
        return this.post.case_history.replace('***', '<br>')
        }
      }

-

<div v-html="postCased"></div>

Codepen

Upvotes: 2

Related Questions