Coming from my background in React with JSX, I am used to setting HTML using code like
var test = <div>i am a div</div>
It is common practice for me. Although I know that the same result can be achieved using v-html in Vue, I was curious about whether it is the best and safest approach when looking at the following code:
This is a Vue component
<template src="./templates/General.html"></template>
<script>
export default {
name: 'guide-general',
data: function() {
return {
guides: [
{
title: "first",
description: "First description"
},
{
title: "second",
description: "Second description"
},
{
title: "third",
description: `<ul>
<li>
test
</li>
</ul>`
}
]
}
},
methods: {
}
}
</script>
<style scoped>
</style>
And here is the HTML template
<article>
<div v-for="guide in guides">
<h4>{{ guide.title }}</h4>
<div v-html="guide.description">
</div>
</div>
</article>