[Vuejs]-Vuejs v-for on object should not order by index

0👍

Its a bad idea to loop an object. Use an array instead

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!',
    members: [
        {'name':'Andreas', "age":39},
        {'name':'Frank', "age":21},
        {'name':'Dieter', "age":2},
        {'name':'Klaus', "age":66}]
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
    <h1>{{ message }}</h1>
    <ul v-for="member in members" v-bind:key="member.name">
        <li> {{ member.name }} {{ member.age }}</li>
    </ul>
</div>

Leave a comment