For loop in vue js

The Loop concept in VueJS facilitates the execution of a set of instructions repeatedly while some condition evaluates as true. In order to repeat a task a fixed amount of time, we make use of the for loop. There are different ways of using a for loop, which is given below:

<template> 
    <h1 v-for="values in val" :key="values.id">{{ values.name }}</h1>
</template>
<script>

   export default {
      name: "HeaderComponent",
      props: ['newArr'],
      methods: {
         eventCall(){
      }
    },

      data() {
         return {
            val : [
               {id:1, name: 'Pankaj'},
               {id:2, name: 'Suraj'},
               {id:3, name: 'Raam'}
            ]
         }
      }

   }

</script>

 

Leave a Reply