david
david

Reputation: 6805

How to bind css class in vue js template within a v-for loop?

How do I name my td class the name of the step in this example?

<td v-for="steps in item.steps" v:bind:class="item.steps.name">
 {{ item.steps.name }}
</td>

In this example, my class gets literally named items.steps.name rather than the return value. Everything else works.

Upvotes: 0

Views: 107

Answers (2)

Orkhan Alikhanov
Orkhan Alikhanov

Reputation: 10060

Use v-bind:class not v:bind:class

Upvotes: 1

r0ulito
r0ulito

Reputation: 487

That's cause you are looping over item.steps with each iteration named steps and you use the variable you are looping over in the class-binding.

Try steps.name instead.

Upvotes: 0

Related Questions