Answer the question
In order to leave comments, you need to log in
How to add v-bind:style to first element created in v-for loop?
I'm making a slider. To move it, I change the margin of the first element. Margin is conditionally calculated.
Elements are created through v-for, you need to add v-bind:style to the first element
How to do this?
Answer the question
In order to leave comments, you need to log in
You need to declare an index for the c v-for block:
then:
v-for="(item, index) in items"
v-bind:style="index == 0 ? {стили для первого элемента} : {}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question