J
J
jeruthadam2018-12-27 11:09:50
Vue.js
jeruthadam, 2018-12-27 11:09:50

Is it possible to add a value in every v-for loop in a template?

Is it possible to do something like this?

<my-component v-for="i in 3" :key="i" :delay="+=0.5">

This does not work.
We must add a value on each cycle. Well, do not create a global variable for this.
It's not clear why this code doesn't work. After all, Vue holds the value of the index, why can't he perform such a simple operation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ihor Bratukh, 2018-12-27
@jeruthadam

Pass index to the method and read there.

0
0xD34F, 2018-12-27
@0xD34F Vue.js

Vue holds the value of the index, why can't he perform such a simple operation?

Or maybe it's something you can't (or don't understand)?
Maybe you need something like ? - try it, suddenly fit. :delay="i * 0.5"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question