<div
v-for="(item, key) in daySchedule"
:key="key"
class="date">
</div>
current : i have 3 object daySchedule
expected : i want to limit to 2 object daySchedule
<div
v-for="(item, key) in daySchedule"
:key="key"
class="date">
</div>
current : i have 3 object daySchedule
expected : i want to limit to 2 object daySchedule
I get item and index from daySchedule data. I set index as key. I set as less than 2 because index started from 0. I hope I made myself clear. This code give to you 2 object
<div v-for="(item, index) in daySchedule" :key="index" class="date">
<div v-if="index < 2 ">
{{item.date}}
</div>
</div>
My example data is here :
data: function () {
return {
daySchedule: [{
id:"1",
date:"2021",
},
{
id:"2",
date:"2020",
},
{
id:"3",
date:"2019",
}],
};
},