Search⌘ K
AI Features

Rendering HTML

Understand how to render HTML safely within Vue applications by using v-html and render functions while avoiding common security pitfalls. Learn the importance of sanitizing user-generated content with tools like dom-purify to prevent script injection and protect your app from vulnerabilities.

We'll cover the following...

Rendering ways

Vue provides a few ways to render string as HTML:

  1. Using a directive called v-html
  <div v-html="userContent"></div>
  1. Using a render function
h('div', {
  domProps: {
     innerHTML: this.userContent 
  }
})
...