Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Vue.js Basics Sweeping Vues: Loops, Methods, Directives List Rendering with v-for

Vue JS color

Hey guys!! I just finished the tutorial, but I have one thing that I dont know, that is when the style set to 'item', is the 'item' referring to the v-for 'item'?

I just want to know where does the value come from.

Thank you so much!!

1 Answer

Daniel Millier
Daniel Millier
16,342 Points

I know this is a year old, but to answer your question:

<li v-bind:style="{color:color}" v-for="color in rainbow">{{color}}</li>
  • The first property of 'color' is referring to the CSS selector to change the text color.
  • The second property-- between the colon ( : ) --is referring to the item we want to apply the style to.

We can name the item any name we want, such as 'basketball', like so:

<li v-bind:style="{color:basketball}" v-for="basketball in rainbow">{{basketball}}</li>

Hope this helps!