From the docs, it shows that we can bind classes to conditions like so:
<div
class="static"
:class="{ active: isActive, 'text-danger': hasError }"
></div>
What if I want to bind two classes to the same condition, would this work? Would there be a shorter way?
<div
class="static"
:class="{ active: isActive, active: isSelectable }"
></div>
If I understand you correctly you want to bind multiple classes to the same condition. There's nothing preventing you from doing it like this if you wanted to ..
<div
class="static"
:class="{ 'class-1 class-2': condition }"
></div>
You can use || and && to combine conditions:
<div
class="static"
:class="{ active: isActive || isSelectable }"
></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With