Currently, I am delving into the world of Vue.js to broaden my knowledge and gain practical experience.
While following a tutorial, I encountered an interesting scenario involving the addition of a class to a span element based on a condition within a v-for loop. The solution involved using an expression enclosed in single curly braces as demonstrated below:
<p v-for="todo in todos" :key="todo">
<span :class="{'is-completed' : todo.completed}">{{ todo.title }}</span>
</p>
The variable todo.completed
is a boolean value.
I'm curious to understand the functionality behind
{'is-completed' : todo.completed}
. It seems reminiscent of object syntax in JavaScript. How does this structure work with the v-bind directive?
Your insights would be greatly appreciated!