Vue Js For Loop Example Tutorial

24-Jul-2020

.

Admin

Vue Js For Loop Example Tutorial

Hi Guys,

In this tutorial, I will explain you how to use for loop in vue js. I show for loop example in vue js. We can use the v-for directive to render a list of items based on an array. The v-for directive requires a special syntax in the form of item in items, where items is the source data array and item is an alias for the array element being iterated on

Example


<!DOCTYPE html>

<html>

<head>

<title>Vue.Js For Loop Example</title>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-alpha1/css/bootstrap.min.css">

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

</head>

<body class="bg-dark">

<div class="container">

<div class="col-md-6 offset-md-3">

<div class="card mt-5">

<div class="card-header">

<h5 v-bind:class="red">Vue.Js For Loop Example</h5>

</div>

<div class="card-body">

<div class="row">

<div class="col-md-12">

<ul>

<li v-for="item in items" v-text="item.message"></li>

</ul>

</div>

</div>

</div>

</div>

</div>

</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>

<script>

Vue.config.devtools = true

var app = new Vue({

el:'.card-body',

data:{

items:[

{ message: 'Php' },

{ message: 'Laravel'},

{ message: 'Java'},

{ message: 'Html'},

],

}

})

</script>

</body>

</html>

It will help you..

#Bootstrap 4

#Html

#Css

#Vue.Js