vuejs
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Class and Style Bindings 86<br />
Changed backround color<br />
We have applied a class to the body for our convenience and now body is referenced within our el<br />
property. What this code actually does, is “flipping” the background color with a hit of the button.<br />
Pressing it invokes the flipColor function that reverses the value of “color” originally set to true.<br />
Then the v-bind:class is going to toggle the class name to ‘body-red’ or ‘body-blue’ conditionally<br />
depending on the truthfulness of “color” value. That given, the style is going to apply on each class<br />
and give us the desired result according to which class is active.<br />
Info<br />
The v-bind:class directive can co-exist with the plain class attribute.<br />
So in our example, body always has the text-center class and conditionally one of<br />
body-red or body-blue.<br />
Warning<br />
Although you can use mustache interpolations such as class=”{{ className }}” to bind the<br />
class, it is not recommended to mix that style with v-bind:class. Use one or the other!