v-html will render them as plain HTML rather than encoding them.
Updates the element's innerHTML
. Note that the contents are inserted as plain HTML - they will not be compiled as Vue templates.
v-html will render them as plain HTML rather than encoding them.
Updates the element's innerHTML
. Note that the contents are inserted as plain HTML - they will not be compiled as Vue templates.
Below the #Example 1
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<div v-html="content"></div>
</div>
<script>
new Vue ({
el: '#app',
data: {
content: '<h2>Hello World</h2>'
}
})
</script>
</body>
</html>
In previous example, v-text
did not render the h3
tag, here we'll use v-html
directive to render the <h3>
Output