<!DOCTYPE html>
<html>
<head>
<title>v-html Directive</title>
<style>
#app > div {
border: dashed black 1px;
width: 220px;
padding: 20px;
margin: 20px;
font-weight: bold;
background-color: lightgreen;
}
</style>
</head>
<body>
<h1>Example 'v-html'</h1>
<p>In the first div element, we try to output the list with text interpolation (curly braces), but it comes out as plain text.</p>
<p>In the second div element, we manage to output the list containing HTML tags, using the v-html directive.</p>
<div id="app">
<div>{{ htmlContent }}</div>
<div v-html="htmlContent"></div>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const app = Vue.createApp({
data() {
return {
htmlContent: '<ol><li>Tomatoes</li><li>Potatoes</li></ol>'
}
}
})
app.mount('#app')
</script>
</body>
</html>