Vue.js Get Array Length
Vue.js Get Array Length– JavaScript .length property can be used to get the length of array or object.
Vue.js Get Array Length | Object length| Example
You can get length of any array or object simply as below-
Example:
<!DOCTYPE html> <html> <head> <script src="http://cdn.jsdelivr.net/vue/1.0.16/vue.js"></script> </head> <body> <ul id="exampleApp"> <li v-if="items.length">Object Length = {{items.length}}</li> <li v-for="item in items"> {{ item.fruit }} </li> </ul> <script> var exampleApp = new Vue({ el: '#exampleApp', data: { items: [ { fruit: 'Mango' }, { fruit: 'Apple' }, { fruit: 'Banana' } ] } }); </script> </body> </html> |
Ouput of above example-
Advertisements