Issue
I'm trying to append multiple classes when the user clicks on a item i have this this:
<div :class="[ item === form.score ? 'text-black bg-white': '' ]"
@click="form.score = item"
v-for="item in 10">
{{ item }}
</div>
But it does only append the bg-white
. Is there a better way?
Solution
You can do that in multiple ways:
:class="[ item === form.score ? 'text-black': '', item === form.score ? 'bg-white': '']"
or
:class="[ 'text-black': item === form.score, 'bg-white': item === form.score ]"
or
:class="[ 'text-black bg-white': item === form.score]"
Answered By - Saeed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.