0👍
✅
Use an array instead of Object to return your value:
<a class="tab" v-bind:class="[activeClass]">
You can make you code more clean like this:
<a :class="['tab', activeClass]">
0👍
You can use a local data to add a certain class on your views, something like this:
<div v-bind:class="{ active: isActive }"></div>
On your js:
data: {
isActive: true,
hasError: false
}
FYI you can use
just :class (without the v-bind) and it will be perfect aswell.
That code will add the ‘active’ class to the div if the isActive
property returns true
Source: Docs and personal usage ( https://vuejs.org/guide/class-and-style.html#Object-Syntax )
Source:stackexchange.com