Skip to content
Advertisement

Vue.js, options for multiple classes on v-bind

I need some help trying to figure out how to give the v-bind:class multiple options.

My Uno game, as it loops through your cards, needs to look at the cards color which is in a list of objects ex. ([{ Color: green, Value: 6}] and determine what color of text the card should be.

This is what I have come up with so far:

Vue.js

JavaScript

HTML

JavaScript

CSS

JavaScript

Advertisement

Answer

Since there’s one property called Color inside the card object you could use style object syntax and you don’t need to define classes for each color:

JavaScript

JavaScript
JavaScript
JavaScript
Advertisement