I have a problem with javascript. I have data as contained in variable datas. I want to display data from the data variable in a table form as below.
the meaning of etc is the date of the dateTo field in the data object. To be clear, the dateFrom and dateTo fields, which are originally date ranges, will be outputted into a date array starting from the date in dateFrom to the date in dateTo. For the date format to be used is new Date(). What I'm thinking is the possibility of using computed or method to get the contents for arrayDates based on dateFrom and dateTo. The overview of output for the date array is something like this:
arrayDates:["2022-01-24", "2022-01-25", "2022-01-26", ... "2022-02-28"].
Does anyone understand the case I have? Thanks.
<script>
export default {
data(){
return {
datas: [
{
"id": 1,
"name": "Sandra Brooke",
"schedule_time": [
{ "id": 1,
"dateFrom": "2022-01-24",
"dateTo": "2022-02-28",
"schedule_day": [
{"id" 1,"days": "Monday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 2,"days": "Tuesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 3,"days": "Wednesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 4,"days": "Thursday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 5,"days": "Friday", "startTime": "08:00:00", "endTime": "16:00:00"},
]
}
]
},
{
"id": 2,
"name": "Michael Anderson",
"schedule_time": [
{ "id": 1,
"dateFrom": "2022-01-24",
"dateTo": "2022-02-28",
"schedule_day": [
{"id" 1,"days": "Monday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 2,"days": "Tuesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 3,"days": "Wednesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 4,"days": "Thursday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 5,"days": "Friday", "startTime": "08:00:00", "endTime": "16:00:00"},
]
}
]
},
{
"id": 3,
"name": "Sarah Black",
"schedule_time": [
{ "id": 1,
"dateFrom": "2022-01-24",
"dateTo": "2022-02-28",
"schedule_day": [
{"id" 1,"days": "Monday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 2,"days": "Tuesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 3,"days": "Wednesday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 4,"days": "Thursday", "startTime": "08:00:00", "endTime": "18:00:00"},
{"id" 5,"days": "Friday", "startTime": "08:00:00", "endTime": "16:00:00"},
]
}
]
},
],
}
},
methods: {
},
}
