Vue V Bind Class

Posted on  by admin
In this guide, we will look at class binding with the Vue v-bind directive.

Class binding comes in handy when we have the need of manipulating an element’s class list.

We can either pass an object or array to dynamically toggle a class. The above syntax means that the class . The above syntax means that the class active would be present on the said element( a div in this instance ) as long as the expression evaluates to true.Multiple classes can also be bound as seen here:.

Array SyntaxWe can as well pass an array to apply a list of classes.

In Vue, v-bind lets you bindan HTML attribute to a JavaScript expression. There are two broad use cases forthis one-way data binding:.

Binding to built-in attributes, like href or class.

MatthewMatthew
379
Robert Pounder
1,368