Reputation:
I want to add an active class while the first button is clicked and remove the active class if it's there in the second button same condition for the second button how can I achieve it.
<button
:class="{ active: isActiveAc, sortas: true }"
@click="sortUp()"
>
Price low to Hight
</button>
<button
:class="{ active: isActiveDc, sortas: true }"
@click="sortDown()"
>
Price Hight to Low
</button>
Upvotes: 0
Views: 722
Reputation: 2331
I would like to give you a basic idea which might help you.
<button :class="{ active: isActiveAc, sortas: true }"@click="sortUp(),setFalse(1)>Price low to Hight</button>
<button:class="{ active: isActiveDc, sortas: true }"@click="sortDown(),setFalse(1)">Price Hight to Low</button>
and add the following function in a method.
setFalse(c) {
if (c == 1) {
this.isActiveAc = true;
this.isActiveDc = !this.isActiveAc;
} else if (c == 2) {
this.isActiveDc = true;
this.isActiveAc = !this.isActiveDc;
}
},
Upvotes: 1