D
D
dicem2020-02-21 17:05:04
Vue.js
dicem, 2020-02-21 17:05:04

Is it possible to add new properties to array elements in v-for?

The question is. An array with comments comes from the server. I iterate through it with v-for and render the elements. Suppose we have the following set:

arr: [
  { name: 'John', age: 13 },
  { name: 'Johny', age: 14 },
  { name: 'Johnathan', age: 15 },
]

and here I render the list:
<ul>
  <template v-for="(item, index) in arr">
    <li :key="index">{{ item.name }} {{ item.age }}</li>
  </template>
</ul>


Can I somehow add new properties for each item in the v-for step?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-02-21
@dicem

No. Make a computed property with all properties added and render it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question