Vue JS Get Array Length Or Object Length Tutorial
Hi Guys,
Today, I will learn you how to get array length or object length in vue js. we will show example of vue js get array length or object length. i will give example for vue js get object length. if you worked with javascript jquery then you know you can get array length by variable.length so same way you can get array length or object length in vue js application.
I give you bellow very simple example so you can understand how to getting array length or object length in vue js code.
Example
<!DOCTYPE html>
<html>
<head>
<title>Vue JS Get Array Length Or Object Length Example - Nicesnippets.com</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
<ul id="exampleApp">
<li v-if="myArray.length">Object Length = {{ myArray.length }}</li>
<li v-for="value in myArray">
{{ value.category }}
</li>
</ul>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
myArray: [
{ category: 'Laravel' },
{ category: 'PHP' },
{ category: 'Wordpress' },
{ category: 'Codeigniter' }
]
}
})
</script>
</body>
</html>
Output
Object Length = 4
Laravel
PHP
Wordpress
Codeigniter
It will help you...
- How to Build VUE JS CRUD Using Node js Express and MySQL?
- Vue js File Upload Axios Php Example
- Vue Js Application Check Current Version In Ubuntu
- Vue JS Download File using Axios Example
- Vue JS Declare Global Variable Example
- Vue Js Sweetalert Modal Notification Tutorial
- Vue Js Get Element By Id Example
- Vue Js Toggle Switch Button Tutorial