0

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.

1
  • computed should be an object... Commented Oct 2, 2018 at 11:48

2 Answers 2

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

-

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

Codepen

Sign up to request clarification or add additional context in comments.

7 Comments

now i have this error:Invalid value for option "computed": expected an Object, but got Function. and Error in render: "ReferenceError: post is not defined"
ok perfect but the text that i have change evretime only the *** are same how can change this
@sofiane could you explain that a bit more? what text and why is it different and what you wanna do with the text etc....?
ok the text have more then 50 line and if i put break each time where is the star then it will be easy to understand the content the text change each timethat we take other cases but every text on each cases have the stars ***
@sofiane sorry im not sure if im just too dumb but i dont understand the current problem ^^
|
0

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>');
    }
}

Comments

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.