A
A
applecode2019-03-18 19:50:44
Vue.js
applecode, 2019-03-18 19:50:44

How to set unique id in v-for loop?

I display elements in a loop using v-for. How can I give the rendered element a unique id attribute?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2019-03-18
@applecode

The code will not need to be understood? At least the structure of the array element was given.
In this case, in the forehead you can do this:

<div v-for="(item, index) in items" :key="index" :id="index"></div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question