[Vuejs]-Calendar component in Nuxt

0👍

When you are constructing your array you can create an array of objects like this :

let monthDate = moment().startOf("month");
this.days = [...Array(monthDate.daysInMonth())].map((_, i) => {
  return {
    date: monthDate.clone().add(i, "day"),
    workhours: 0,
    overtime: 0
  };
});

In the map function we return an object instead of just a single property

<div v-for="(day, index) in days" :key="index" class="grid-container">
  <p class="grid-item">{{ day.date.format("Do") }}</p>
  <p class="grid-item">{{ day.date.format("dddd") }}</p>
  <p class="grid-item">{{ day.workhours }}</p>
  <p class="grid-item">{{ day.overtime }}</p>
</div>

Leave a comment