panthro
panthro

Reputation: 24061

Binding a class from var and string?

How can I output a class from a var and also a string in a blade template?

<div :class="data['type'], 'string-class'" v-for="(data, index) in products"></div>

Something like the above.

Upvotes: 1

Views: 39

Answers (1)

jacky
jacky

Reputation: 1446

you can use:

<div :class="[data['type'], 'string-class']" v-for="(data, index) in products"></div>

if string-class just is a string not a var ,you can use:

<div class="string-class" :class="data['type']" v-for="(data, index) in products"></div>

Or more combinations.

Upvotes: 3

Related Questions