Two days ago my developer was working with array in vue js and he need to get length of array. he was new with javascript then he told me for help. i create simple example of get array length in vue js and get object length in vue js, so understood very well that thing.
I give you bellow very simple example so you can understand how to getting array length or object length in vue js code.
My Example:
<!DOCTYPE html>
<html>
<head>
<title>Vue JS Get Array Length Or Object Length Example - ItSolutionStuff.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: 'Codeigniter' }
]
}
})
</script>
</body>
</html>
Output:
Object Length = 3
Laravel
PHP
Codeigniter
I hope it can help you...
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example