I'm trying to set a dynamic class in a vue.js, something like
<strong :class=`color-${category.level}`>{{ category.name }}</strong>
this html is inside a for loop and I need the category.value on this loop but it's not working
Add function in :class in your case
:class="switchClass(category.level)"
and then in methods
switchClass(level) {
return `color-${level}`
}
template. But again, you should just do it the way it works for you and your team, I am talking from a more general point of view