[Vuejs]-Vue change style in for Conditionally

0👍

You can use dynamic class binding via v-bind to dynamically change the class as following:

<li v-for="cervejaria in cervejarias">   
   <span v-bind:class="{'myClass' : cervejaria.name == 'foo'}">         {{cervejaria.name}}</span>
</li>

So in above code, myClass will be applied only if condition cervejaria.name == 'foo' is true.

Leave a comment