What is the v-html directive in Vue JS?

In Vue JS, the v-html directive is used to change the content of an HTML element. It is similar to the DOM innerHtml property.

Syntax

v-html accepts a single parameter, data, as input and renders it into HTML.

v-html="data"

Example

Explanation

First, we created a div element with an id app, and applied the v-html directive to it with data as the input.

Then, we created a message by initializing a new Vue instance with the data property containing our message.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources