I am trying to render a list of names using v-for. I have an array of names and I am able to create the template and render the names in the div. What I want to do is if I add any new object in my data, how can I render that part onwards of the data in a new template. So for example, everything until name 'michael' is rendered in one div, but if I add a new name to the data, from that point onwards the names should be rendered inside another template. Here is a CodePen showing my problem
new Vue({
el: '#app',
data() {
return {
myArray: [{
name: 'Sam',
value: 'sam'
},
{
name: 'Gary',
value: 'gary'
},
{
name: 'Smith',
value: 'smith'
},
{
name: 'Sunny',
value: 'sunny'
},
{
name: 'Michael',
value: 'michael'
}
]
}
}
})
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<v-app id="inspire" class="ml-4">
<template>
<div v-for="person in myArray" key="person.name">
{{person.name}}
</div>
</template>
<template>
//New names should be rendered here from the new values added to the data?
</template>
</v-app>
</div>
Any help will be appreciated. I hope I have explained my need. If not let me know.
Array.prototype.concat().