My array has a nested structure like this:
"meetingTime":[
[
{
"date":"2021-05-30",
"startTime":"15:30",
"endTime":"11:11"
}
],
[
{
"date":"2021-06-29",
"startTime":"17:00",
"endTime":"19:00"
}
],
[
{
"date":"2021-06-29",
"startTime":"14:00",
"endTime":"15:06"
},
{
"date":"2021-06-29",
"startTime":"14:00",
"endTime":"12:00"
}
]
]
}
]
I am trying to loop through this array and display the available times for each date. For instance, for the date 2021-06-29, the available times would be startTime 14:00 - 12:00 and startTime 14:00 - 15:06. Here is how I have constructed my array:
<script>
import DatePickerComponent from "@/components/DatePickerComponent";
export default {
name: "GenerateMeetingSettings",
data: () => ({
selectedTime: [],
finalMeeting: [],
datesFinal: [{meetingName: "",
meetingTime: []}] ,
dates: new Date().toISOString().substr(0,10),
meetingSettingUrl: "",
meetingPW: "",
generatedLink: false,
meetingName: "",
dialog: false,
menu: false,
modal: false,
menu2: false,
menu3: false
})
,
methods:{
addTimeFields(){
this.selectedTime.push({
date: this.dates,
startTime:"",
endTime: "",
})
},
saveDateAndTIme(e) {
this.datesFinal[0].meetingTime.push(this.selectedTime),
this.selectedTime = []
},
Here is my attempt at displaying the values, but it's not working as expected. Can anyone help me with this issue?
Error message:
[Vue warn]: Property or method "time" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <GenerateMeetingSettings> at src/components/GenerateMeetingSettings.vue
<Home> at src/views/Home.vue
<VMain>
<VApp>
<App> at src/App.vue
<Root>
eval @ main.js?56d7:21
./src/main.js @ app.js:1273
__webpack_require__ @ app.js:849
fn @ app.js:151
1 @ app.js:1358
__webpack_require__ @ app.js:849
checkDeferredModules @ app.js:46
(anonymous) @ app.js:925
(anonymous) @ app.js:928
Show 48 more frames
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'meetingTime' of undefined"
found in
---> <GenerateMeetingSettings> at src/components/GenerateMeetingSettings.vue
<Home> at src/views/Home.vue
<VMain>
<VApp>
<App> at src/App.vue
<Root>
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'meetingTime' of undefined
at Proxy.render (GenerateMeetingSettings.vue?90fe:384)
at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548)
at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066)
at Watcher.get (vue.runtime.esm.js?2b0e:4479)
at new Watcher (vue.runtime.esm.js?2b0e:4468)
at mountComponent (vue.runtime.esm.js?2b0e:4073)
at VueComponent.Vue.$mount (vue.runtime.esm.js?2b0e:8415)
at init (vue.runtime.esm.js?2b0e:3118)
at createComponent (vue.runtime.esm.js?2b0e:5978)
at createElm