[Vuejs]-Vue bind class if values equals false

0👍

Most straightforward approach might be to use a method to compute the class. Here’s a simplified version

<a
    v-for="(policy, index) in policies"
    class="list-group-item"
    :class="getItemClass(policy, index)"
    href="..."
>
    ...
</a>

Then

methods: {
    getItemClass(policy, index) {
        let itemClass = "";
        // ... whatever logic you want to calculate the classname
        return itemClass;
    }
}

Leave a comment