0👍
✅
Since you’re iterating over filterList
, you need to use a method instead of a computed property`
methods: {
classObject: function (hotel) {
return {
'spa': hotel.spa,
'two-star': hotel.star,
'family': hotel.family
}
}
}
And then in the template
<div
v-for="hotel in filteredList"
class="card"
v-bind:class="classObject(hotel)"
>
(I removed the id
since that’s going to result in multiple elements with the same id.)
Source:stackexchange.com