0

I am developing an application using Laravel & Vue.js. I have some data in database like Hello <b>world!</b>. How can I display them as Hello world! ?

1 Answer 1

6

Use the v-html binding:

<p v-html="fromDB"></p>

assuming you have a fromDB property in your viewmodel like e.g.

data() {
  return {
    fromDB: 'Hello <b>world!</b>'
  }
}

Example:

https://codesandbox.io/s/2po80169wy

Reference:

https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML

Please be aware that this comes with a risk since from your database, fromDB can become just about anything, e.g. <script>console.log('logged')</script>.

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

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.