O
O
obemgcabazn2020-08-01 14:25:29
Vue.js
obemgcabazn, 2020-08-01 14:25:29

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

1 answer(s)
A
alexalexes, 2020-08-01
@obemgcabazn

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 question

Ask a Question

731 491 924 answers to any question