Iterating over objects in Vue

Objects are also iterated over using the v-for directive. Let's see how this is done. Let's say we have the following object:

javascriptdata() {
  return {
    obj: {a: 1, b: 2, c: 3},
  }
}

Let's iterate over this object and display its elements:

App.vue<template>
  <p v-for="elem in obj">
    {{ elem }}
  </p>
</template>

Now let's output both the keys and the elements:

App.vue<template>
  <p v-for="(elem, key) in obj">
    {{ key }} {{ elem }}
  </p>
</template>

Now let's also output the ordinal numbers of the elements in the object:

App.vue<template>
  <p v-for="(elem, key, index) in obj">
    {{ index }}
    {{ key }}
    {{ elem }}
  </p>
</template>
Задание 1

The following object is given:

javascript{
  user1: '100$',
  user2: '200$',
  user3: '300$',
}

Use v-for to print the following:

<ul> <li>100$</li> <li>200$</li> <li>300$</li> </ul>
Задание 2

The following object is given:

javascript{
  user1: '100$',
  user2: '200$',
  user3: '300$',
}

Use v-for to print the following:

<ul> <li>user1 - 100$</li> <li>user2 - 200$</li> <li>user3 - 300$</li> </ul>
Задание 3

Rework the previous task so that at the end of each li there is also a serial number of the element in the object. Like this:

html<ul>
  <li>user1 - 100$ - 0</li>
  <li>user2 - 200$ - 1</li>
  <li>user3 - 300$ - 2</li>
</ul>
Задание 4

Rework the previous problem so that the numbers start with one instead of zero. Like this:

html<ul>
  <li>user1 - 100$ - 1</li>
  <li>user2 - 200$ - 2</li>
  <li>user3 - 300$ - 3</li>
</ul>