You mix your approaches slightly. The main problem is v-bind:class="{'className':isLoading}" . This directive, as you wrote it, switches the class with the name "className" (literally this, not the value of the className variable) to your element if isLoading is true . If it is false , it does not assign any class.
By looking at your code, it seems you are actually trying to set two different classes depending on what isLoading . The easiest way to do this is to use v-bind:class="isLoading ? 'color-red' : 'color-blue" . Take a look at a working example here .
An even better solution that does not pollute your template with logic is to move this expression into a computed property like this .
source share