Categories
Vue Answers

How to display unescaped HTML in Vue.js?

Spread the love

Sometimes, we want to display unescaped HTML in Vue.js.

In this article, we’ll look at how to display unescaped HTML in Vue.js.

How to display unescaped HTML in Vue.js?

To display unescaped HTML in Vue.js, we can set the v-html directive to the reactive property string with the HTML we want to display.

For instance, we write

<template>
  <section v-html="desc"></section>
</template>

to add the v-html directive to the section element and set its value to desc to render as the content of desc as raw HTML.

Conclusion

To display unescaped HTML in Vue.js, we can set the v-html directive to the reactive property string with the HTML we want to display.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *